lua-users home
lua-l archive

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

This is something I've often wished to have in various languages, and
I accidentally discovered that it's valid syntax in Lua:

if x < y < z then...

Of course, it doesn't actually work, because it evaluates as "(x < y)
< z", and "(x < y)" evaluates to a boolean. (I couldn't find a way to
make clever metamethods that would allow it to work either, since
__le's result is always converted to a boolean, so you lose the values
of x and y.)

(The idea of course is that it evaluates as "x < y and y < z".)

Just something I noticed and thought was interesting.

Sent from my Game Boy.