Re: Ternary operator patch
[
Date Prev][
Date Next][
Thread Prev][
Thread Next]
[
Date Index]
[
Thread Index]
- Subject: Re: Ternary operator patch
- From: Jonathan Castello <twisolar@...>
- Date: 2010年9月12日 15:56:05 -0700
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
- References:
- Re: Ternary operator patch, Henk Boom
- Re: Ternary operator patch, steve donovan
- Re: Ternary operator patch, Geoff Leyland
- Re: Ternary operator patch, steve donovan
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Miles Bader
- Re: Ternary operator patch, David Kastrup
- Re: Ternary operator patch, Jonathan Castello
- Re: Ternary operator patch, Roberto Ierusalimschy
- Re: Ternary operator patch, Enrico Tassi
- Re: Ternary operator patch, Doug Rogers
- Re: Ternary operator patch, HyperHacker
- Re: Ternary operator patch, GrayFace