From: "Jesús Gabriel y Galán" Date: 2010-04-05T23:45:50+09:00 Subject: Re: When {integer:0} <> 0 ??? On Mon, Apr 5, 2010 at 4:35 PM, Richard Fairbanks wrote: > Brian Candler wrote: >> Richard Fairbanks wrote: >>> if p(Y.z): 0  # I assume this is the culprit! >>>   osax.say(Y.z)    #=> silence >>> end >> >> What are you trying to do here? > > Thank you for the response, Brian! > > (Y,z) is initially defined as 0: >    module Y; def self.z; 0; end; end > > and both: >    osax.say(Y.z)    #=> "zero" and >    p(Y.z)  #=> {integer:0} > validates that Y.z) = 0 > > What if statement do I have to write to get Ruby to recognize an > existing value? if (Y.z == 0) osax.say(Y.z) end you have two errors: p(Y.z) as Brian explained is calling Kernel#p which always returns nil, and so using that return value in an if is not what you want. The second error is using : 0, when you are trying (I think) to compare the result of Y.z with 0. What follows the colon is the first statement in the if body, not a value to compare to. Jesus.