From: Tristin Davis Date: 2008-06-27T02:49:35+09:00 Subject: Re: A cleaner way to pass a block or proc ------=_Part_5077_15701646.1214502709497 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline The final result. def add_notifier(notifier=nil, &block) raise ArgumentError, "Nil notifier. You must provide a Proc or a block" if notifier.nil? && block.nil? @notifiers << (notifier || block) end On Thu, Jun 26, 2008 at 10:19 AM, Ben Bleything wrote: > On Thu, Jun 26, 2008, Jess Gabriel y Galn wrote: > > I think you could end up adding some nils with > > this solution and the previous one, if I call: > > > > Heartbeat.new.add_notifier > > > > without any argument or block. > > Right, this is why I suggested modifying the block to handle the nils :) > > Ben > > ------=_Part_5077_15701646.1214502709497--