From: Jason Mayer Date: 2006-12-20T21:36:10+09:00 Subject: Re: ruby gotchas ------=_Part_13767_10058841.1166618168676 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 12/19/06, Peter Szinek wrote: > > Mark Guzman wrote: > > I've written up some ruby gotchas that have come up while using ruby. > > I'm wondering if there are any other gotchas that I should be aware of. > > The list is available at: > > http://hasno.info/2006/12/14/ruby-gotchas-and-caveats > > > > I was considering adding &&= to the list as it's functionality seemed a > > bit odd to me at first. > > --mark > > > From the 'Ruby way': > > foo = false > bar = true > > baz = foo or bar > > baz ends up false (because = has greater priority than or) > > Cheers, > Peter > > __ > http://www.rubyrailways.com > > interesting. So instead of 'or' always use || unless I've got a good reason not to. Got it. That's a good one to know. irb(main):001:0> a = false => false irb(main):002:0> b = true => true irb(main):003:0> c = a or b => true irb(main):004:0> puts c false => nil irb(main):001:0> a = false => false irb(main):002:0> b = true => true irb(main):003:0> c = a || b => true irb(main):004:0> puts c true => nil ------=_Part_13767_10058841.1166618168676--