lua-users home
lua-l archive

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

On Mon, Apr 24, 2017 at 10:22 PM Hisham <> wrote:
Also, I had never noticed before that parentheses coerce nothing to
nil. Learn something new every day, even in a small language like Lua!

> type((string.byte("hello", 10)))

-- Hisham

More properly, parentheses adjust an arbitrary number of values to exactly one value. Zero values becomes nil, but multiple values cause the second and subsequent values to be discarded. Example:

> string.byte("hello", 3, 5)
108 108 111
> (string.byte("hello", 3, 5))