From: Trans Date: 2008-10-03T04:20:48+09:00 Subject: Re: Is Assignment in a Conditional an Idiom? On Oct 2, 2:55 pm, "Robert Dober" wrote: > On Thu, Oct 2, 2008 at 8:38 PM,   wrote: > > Hi > > > I was just reading the following blog post > >http://www.elctech.com/blog/clarity-over-cleverness-but-what-is-clever, > > and like the author, it is the first time I have seen code as he > > describes.  From the comments it would seem that some think it is an > > idiom to be used, and perhaps others do not. > > > Just curious as to how common this use it?  I do tend to side with > > view that it is not clear at first glance. > > > Thanks > > Richard > > It seems very bad code to me, what is wrong with the following? >    @attributes['comments'] = @attributes['comments'].split( " " ) > rescue @attributes['comments'] > although I suspect that >          ... @attributes['comments'].split ... > is what the good fellow really wants. I wouldn't recommend that. Rule of thumb, don't use rescue when a regular condition does the job. Also one must consider if there is a difference between key presence and key returning nil. In which case it may be better to use: if @attributes.key?('comments') T.