From: dblack@... Date: 2006-12-24T05:21:36+09:00 Subject: Re: Help with a ruby idiom Hi -- On Sun, 24 Dec 2006, M. Edward (Ed) Borasky wrote: > Might I be a curmudgeon on this Christmas eve eve? I say that any idiom > that's confusing enough that its semantics isn't *instantly* recognizable to > an old FORTRAN programmer like my curmudgeonly self probably doesn't > contribute to code readability. :) So I would write this out in "longhand" > and not let the parser have an opportunity to confuse me. So my "idiom" would > be > > if (!a) then > a = b > end That won't work though: ruby -e 'if (!a) then a = b end' -e:1: undefined local variable or method `a' for main:Object (NameError) because of the forward reference to a. > Or, since my curmudgeonly self has managed to learn Perl, :) > > a = b if !a ||= is used a lot in Perl, too :-) I guess I'm just used to it; my eye takes it in pretty readily. David -- Q. What's a good holiday present for the serious Rails developer? A. RUBY FOR RAILS by David A. Black (http://www.manning.com/black) aka The Ruby book for Rails developers! Q. Where can I get Ruby/Rails on-site training, consulting, coaching? A. Ruby Power and Light, LLC (http://www.rubypal.com)