From: Robert Dober Date: 2008-06-26T19:39:53+09:00 Subject: Re: A cleaner way to pass a block or proc On Thu, Jun 26, 2008 at 3:04 AM, Joel VanderWerf wrote: > Tristin Davis wrote: >> >> def add_notifier(notifier=nil, &block) >> if block_given? >> @notifiers << block >> else >> @notifiers << notifier >> end >> end > > def add_notifier(notifier=nil, &block) > @notifiers << (block || notifier) > end I would do it exactly as Jöel suggested above, however there is an interesting alternative one might want to be aware of def add_notfier notifier=nil @notifiers << ( Proc::new rescue notifier) end Cheers Robert -- http://ruby-smalltalk.blogspot.com/ --- Les mêmes questions qu'on se pose On part vers où et vers qui Et comme indice pas grand-chose Des roses et des orties. - Francis Cabrel