Kedar Mhaswade wrote:

> Pascal J. Bourguignon wrote:
>> Kedar Mhaswade <kedar.mhaswade / gmail.com> writes:
>>> puts s
>>> ------------
>>>
>>> Outputs:
>>> test
>>> test
>>> nil
>>>
>>> so, to add to a newbie's confusion, a pair of parenthesis does the
>>> expected.
>> 
>> What did you expect?
>> 
>> case 1:
>> (s = "surprising") if ((1 + 1) != 2)  won't assign unless (1+1)!=2
>> 
>> case 2:
>> s = ("surprising" if ((1 + 1) != 2))  will assign the result of the
>> parenthese, which will be "surprising" if ((1 + 1) != 2) (and nil
>> otherwise).
>> If you wanted not to do any assignment to s, then you should go back
>> to case 1.
> 
> Tim and Pascal,
> 
> I certainly appreciate your attempts to make me get it. I think I am
> close. The only weird thing is I was not sure whether
> "surprising" if (1+1 != 2)
> is an "expression" and if yes, what its value was. I thought that this
> expression is same as ("surprising" if (1+1 != 2)) and both should
> evaluate to the same value.
> 
> Thus, whereas now I get that the value of ("surprising" if (1+1 != 2))
> is nil, it is not clear to me if
> - "surprising" if (1+1 != 2) is an expression and evaluates to
> some/same value.
> 
> Apologies if this is becoming rather lengthy.
> 
> Regards,
> Kedar
> 
> 

I think the response mode irb defaults to, is confusing you.  When you
use irb, for the sake of clarifying what you were expecting previously,
use the --noinspect option (i.e., irb --noinspect).
-- 
Tim Greer, CEO/Founder/CTO, BurlyHost.com, Inc.
Shared Hosting, Reseller Hosting, Dedicated & Semi-Dedicated servers
and Custom Hosting.  24/7 support, 30 day guarantee, secure servers.
Industry's most experienced staff! -- Web Hosting With Muscle!