From: "Berger, Daniel" Date: 2002-05-17T22:40:00+09:00 Subject: RE: ||= operator Oops - I misread the error message when I ran my code snippet. I had a typo. Well, disregard then. :) Dan > -----Original Message----- > From: Nat Pryce [mailto:nat.pryce@b13media.com] > Sent: Friday, May 17, 2002 8:36 AM > To: ruby-talk@ruby-lang.org > Subject: Re: ||= operator > > > From: "Berger, Daniel" > > This is a perl-ism that I use from time to time: ||= > > e.g. > > s = String.new > > s ||= "hello" > > This is just shorthand for: > > s = "hello" if s.nil? > > Any chance of adding this? Or is this too difficult to parse? > > irb(main):001:0> p= nil > nil > irb(main):003:0> p ||= "Hello" > "Hello" > irb(main):005:0> p ||= "Goodbye" > "Hello" > irb(main):006:0> > > Cheers, > Nat. > ________________________________ > Dr. Nathaniel Pryce > B13media Ltd. > Studio 3a, Aberdeen Business Centre, 22/24 Highbury Grove, > London, N5 2EA > http://www.b13media.com > >