On Thu, Oct 2, 2008 at 9:20 PM, Trans <transfire / gmail.com> wrote:
> I wouldn't recommend that. Rule of thumb, don't use rescue when a
> regular condition does the job.

You surprise me here Tom, what is rescue for then, I mean the one line
version of course. However let us assume that you are right, what
really troubles me is the is_a? String or String#=== part of the
condition.
Assuming that you should not use rescue this should be written as follows

@attributes["comments] = @attributes["comments"].split  if
@attributes["comments"].respond_to?(:split)

Do not optimize the three lookups into assignement into a local
variable unless you have performance problems.

However I agree that the assignment to a local variable in an
ifcondition is by all means idiomatic and useful Ruby.

As is the rescue clause, I really would know more about why not to use it.


Robert



-- 
C'est vٔitablement utile puisque c'est joli.

Antoine de Saint Exupٔy