From: Tristin Davis Date: 2008-06-26T08:48:23+09:00 Subject: A cleaner way to pass a block or proc ------=_Part_3836_6853947.1214437834045 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Is there a cleaner way to implement my add_notifier method? def add_notifier(notifier, &block) if block_given? @notifiers << block else @notifiers << notifier end end def thump raise ArgumentError, "You must add_notifier before you can notify" if @notifiers.empty? @notifiers.each {|n| n.call } end Here's how the method will be used. hb.add_notifier nil do puts "Notification1" end meth = lambda{ puts "notification2" } hb.add_notifier(meth) It just seems really unpretty to pass that nil when I want to pass just the block. ------=_Part_3836_6853947.1214437834045--