From: Robert Klemme Date: 2009-04-18T16:35:02+09:00 Subject: Re: simple (?) question regarding the "&&" and "and" operators On 17.04.2009 20:47, Philip Müller wrote: > On Fri, 17 Apr 2009 17:25:37 +0200, Sebastian Hungerecker > wrote: >> Example: foo = ARGV[0] or default_value). > > Thanks, > ruby can be different to understand sometimes for someone coming from > c/c++. Yes, maybe. But if you get the hang of it you will see how useful this is. Actually what the expression returns is a value which is "true" equivalent, i.e. you can do things like if a && b puts "both set" end But also, and this is where the fact is handy that one of the values is returned (the first non false and non nil in this case): x = a || b In C/C++ you might have to do something like x = a == NULL ? b : a; or maybe just x = a ? a : b; (My C has become a bit rusty.) Kind regards robert