lua-users home
lua-l archive

Re: tri-condition

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


function Foo( s )
 --- check this out..
 return (type(s) == "string") and string.format("[%q]", s) or
string.format("[%d]", s )
end
Foo(1) --- "[1]"
Foo("ok") --- ["ok"]
I thought that this way was working with everything ... isn't it ?

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