From: Robert Klemme Date: 2012-05-26T23:43:42+09:00 Subject: Re: looking for a ruby idiom : r=foo; return r if r On Fri, May 25, 2012 at 3:57 AM, Matthew Kerwin wrote: > On 25 May 2012 01:14, Robert Klemme wrote: >> On Thu, May 24, 2012 at 4:50 PM, botp wrote: >> I wouldn't do that, there is a certain risk that it looks like a >> typing error (i.e. someone assumes you meant "if r==foo...") > > Clear documentation and commenting can help there. But where is the point in searching for a short, concise idiom and which then needs added documentation to avoid errors? >> But I think the idiom with "and" is superior. :-) > > It's concise, but it's a very idiomatic idiom.  At a glance it's > harder to understand than the 'if r=foo..' construct (which is also > idiomatic).  If you use it in all your code, however, I won't > complain. ;) I would actually consider it an advantage if it stands out so much as strange: that way you do not glance over it easily (what might happen with "if r=foo") and if you do not know it you'll soon find out. :-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/