lua-users home
lua-l archive

Re: if statement

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


2013年4月15日 Chris Datfung <chris.datfung@gmail.com>:
> Thanks. In this case, I'm stuck with Lua 5.1, is there anything comparable
> to goto in 5.1?
No. You could make a function of the whole thing and say 'return "Blue"'
instead of 'Decision="Blue"'. But here's a neater solution.
function chosen(x) return tonumber(ChooseSetting(x)) end
Decision = (chosen(a) and chosen(b) and chosen(c) and "Blue")
 or (chosen(d) and chosen(e) and "Red")
 or (chosen(f) and "Yellow") or "Orange
The logical functions do shortcut evalation, so it will skip unnecessary
tests.

AltStyle によって変換されたページ (->オリジナル) /