I would expect j to equal true after the run, but it equals nil. If I
change the return values to anything else but true and false, it works
as expected. Am I missing some special handling of true and false?
Thanx.
I would expect j to equal true after the run, but it equals nil. If I
change the return values to anything else but true and false, it works
as expected. Am I missing some special handling of true and false?
Thanx.
I just tried this, and couldn't replicate your result. What Ruby are
you using?
I tried the above and it worked for me as expected:
irb(main):023:0> i = 1
=> 1
irb(main):024:0> j = case i
irb(main):025:1> when 1
irb(main):026:1> true
irb(main):027:1> else
irb(main):028:1* false
irb(main):029:1> end
=> true
irb(main):030:0> j
=> true
···
Russ Cordner <russ.cordner@apptis.com> wrote:
I have the following code fragment:
i = 1
j = case i
when 1
true
else
false
end
I would expect j to equal true after the run, but it equals nil. If I
change the return values to anything else but true and false, it works
as expected. Am I missing some special handling of true and false?
Thanx.
--
Darryl L. Pierce <mcpierce@gmail.com> http://mcpierce.multiply.com/
"What do you care what people think, Mr. Feynman?"