From: Brian Candler Date: 2010-04-05T23:58:44+09:00 Subject: Re: When {integer:0} <> 0 ??? Richard Fairbanks wrote: > Thank you for the response, Brian! > > (Y,z) is initially defined as 0: > module Y; def self.z; 0; end; end That's Y.z, not (Y,z) > and both: > osax.say(Y.z) #=> "zero" and > p(Y.z) #=> {integer:0} > validates that Y.z) = 0 Yes. p(Y.z) shows you that Y.z is 0. > What if statement do I have to write to get Ruby to recognize an > existing value? Just the bare expression, Y.z if Y.z == 0 do_something end Or there's a one-liner form: do_something if Y.z == 0 You could also write if Y.z do_something end and this would work, because any value which is not nil or false is treated as true (so zero is true). The colon is not a comparison operator, it is a (rarely-used) statement separator. It's not what you want here. e.g. if true: puts "hello"; end is same as if true; puts "hello"; end and if true puts "hello" end -- Posted via http://www.ruby-forum.com/.