|
From: Ratnavel P S on 1 Jul 2008 00:31 What does the ruby idiom a ||= b mean? Thanks, Ratnavel -- Posted via http://www.ruby-forum.com/.
From: Rob Biedenharn on 1 Jul 2008 00:49 On Jul 1, 2008, at 12:31 AM, Ratnavel P S wrote: > What does the ruby idiom a ||= b mean? > > Thanks, > Ratnavel It is like: a || a = b See David A. Black's Blog http://dablog.rubypal.com/2008/3/25/a-short-circuit-edge-case -Rob P.S. Please don't ask the same question on both Rails and Ruby lists/ forums. Rob Biedenharn http://agileconsultingllc.com Rob(a)AgileConsultingLLC.com
From: Lars Christensen on 1 Jul 2008 04:26 On Jul 1, 6:49 am, Rob Biedenharn <R...(a)AgileConsultingLLC.com> wrote: > On Jul 1, 2008, at 12:31 AM, Ratnavel P S wrote: > > > What does the ruby idiom a ||= b mean? > > It is like: > a || a = b In english, thats: If a is nil or false, then leave it, else assign a = b. Often used instead of code like this: if a.nil? then a = b end
From: Dave Bass on 1 Jul 2008 06:46 Ratnavel P S wrote: > What does the ruby idiom a ||= b mean? It's commonly used to assign default values to things. This idiom is also very common in Perl, which is presumably where it came from. -- Posted via http://www.ruby-forum.com/.
From: Ruby Freak on 2 Jul 2008 18:08 This has been discussed nearly to death at: http://groups.google.com/group/comp.lang.ruby/browse_thread/thread/fe4fbc48e19105cd/bf7f73380e285aff?lnk=gst&q=Or+equal#bf7f73380e285aff
|
Pages: 1 Prev: [ANN] hoe 1.7.0 Released Next: Need help on e-mail authentication |