From: "Kontra, Gergely" Date: 2002-05-17T22:42:10+09:00 Subject: RE: ||= operator Just cool down! And try it with a class variable :))) @@classVar ||= "Hello" >Oops - I misread the error message when I ran my code snippet. I had a >typo. > >Well, disregard then. :) > >Dan >> >> 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 >> >> > +-[Kontra, Gergely @ Budapest University of Technology and Economics]-+ | Email: kgergely@mcl.hu, kgergely@turul.eet.bme.hu | | URL: turul.eet.bme.hu/~kgergely Mobile: (+36 20) 356 9656 | +-------"Olyan langesz vagyok, hogy poroltoval kellene jarnom!"-------+ . Magyar php mirror es magyar php dokumentacio: http://hu.php.net