From: "David A. Black" Date: 2008-05-02T05:12:27+09:00 Subject: Re: Please explain nuances of ||= Hi -- On Fri, 2 May 2008, Simon Krahnke wrote: > * David A. Black (18:56) schrieb: > >> Hi -- >> >> On Fri, 2 May 2008, Ruby Freak wrote: >> >>> I am reading some of the ruby files in rails and I an seeing the ||= >>> method used a lot. >>> knowing ruby the way I do, I realize that she has lots of magical >>> surprises and I really want to get to know this girl! >> >> x ||= y means: x || x = y > > No, it means: x = x || y This is becoming a bit of a perma-thread :-) See Robert K.'s answer, and also have a look at the blog post I mentioned in my response. It's about exactly why x = x || y is not the right expansion for x ||= y. David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin INTRO TO RAILS June 24-27 London (Skills Matter) See http://www.rubypal.com for details and updates!