2009/2/26 lasitha <lasitha.ranatunga / gmail.com>:
> On Thu, Feb 26, 2009 at 1:24 AM, IƱaki Baz Castillo <ibc / aliax.net> wrote:
>>> It also can hide problems that you won't know that you have. For
>>> example,
>>>  myvar = nil
>>>  othervar = myvar.downcase rescue myvar
>>> Did you want to set othervar to nil also?
>>
>> Not exactly, but myvar could be a Fixnum so othervar would also be a Fixnum.
>> But if myvar is a String then I want othervar to be the same String but
>> downcase.
>
> This may be stating the obvious but code that branches based on type
> is smelly. That is not to say it's always wrong, just always at least
> a little smelly :). Particularly if you find multiple places in the
> code having to deal with Fixnum and String conditionally.
>
> The inline rescue slightly obscures the conditional but the smell
> remains. It may be worthwhile reconsidering whether you really want
> myvar to hold disparate types.
>
> I would also reiterate Rob's concern that this rescue could easily
> hide some unrelated bug (mvay being nil being the most obvious).
>
> These two concerns would be enough for me to reconsider, but as usual,
> it all depends on context.

Yes, you are right, I'll consider it. Thanks a lot.


-- 
Iaki Baz Castillo
<ibc / aliax.net>