lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]

On Mon, Sep 5, 2011 at 21:42,  <> wrote:
> Lua 5.1.4  Copyright (C) 1994-2008, PUC-Rio
>> a={1,2,3}
>> b={9,8,7}
>> c={unpack(a),unpack(b)}
>> =#c
> 4
>> for _,v in ipairs(c) do print(v) end
> 1
> 9
> 8
> 7
> I think the variable c should be {1,2,3,9,8,7}, doesn't it?
> --------------------------------------------------------
> ZTE Information Security Notice: The information contained in this mail is solely property of the sender's organization. This mail communication is confidential. Recipients named above are obligated to maintain secrecy and are not permitted to disclose the contents of this communication to others.
> This email and any files transmitted with it are confidential and intended solely for the use of the individual or entity to whom they are addressed. If you have received this email in error please notify the originator of the message. Any views expressed in this message are those of the individual sender.
> This message has been scanned for viruses and Spam by ZTE Anti-Spam system.

Nope. When you write:
c = {unpack(a), unpack(b)}
Since unpack(a) is not the last item in the list, only its first
return value is added to the table. It is a bit confusing...

Sent from my toaster.