lua-users home
lua-l archive

Re: Switch/Case with Fallthrough

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


What happens if you assign a new value to <variable> inside a case block and dont use break? What value become checked in the next case test? the new assigned one or the local remembred one?
Am 20.11.2013 18:13, schrieb Paige DePol:
switch <variable> -- variable must be global or local
 case <constant> -- constant: nil, true, false, number or string
 <block> -- standard Lua block, all statements valid
 [break] -- optional break, if not present will fall through
 case <constant> -- to the block of the next case statement
 <block>
 [break] -- repeat as many cases as you need
 case <constant> -- specifying a constant more than once will
 <block> -- generate a syntax error at compile time
 [break]
 else -- optional else block if no case conditions matched
 <block> -- if last statement in else is a break it will be
end -- optimised out and will not appear in the bytecode

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