lua-users home
lua-l archive

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


On Sun, Sep 12, 2010 at 3:48 PM, GrayFace <sergroj@mail.ru> wrote:
>
> On 13.09.2010 4:59, HyperHacker wrote:
>>
>> I guess you could hack up a construct like:
>> a = {true=1, false=2}[b ~= nil]
>
> This way both expressions would be evaluated before the check is done, thus
> usually defeating the whole purpose.

Well...

--
a = ({[true]=function() return 1 end, [false]=function() return 2
end})[b ~= nil]()
--

Ugly? Yes.
~Jonathan