You can use the call method, rather than letting handle two separate blocks passed to.
Here's how:
def mood(state, happy, sad ) if (state== :happy) happy.call else sad.call end end mood(:happy, Proc.new {puts 'yay!'} , Proc.new {puts 'boo!'}) mood(:sad, Proc.new {puts 'yay!'} , Proc.new {puts 'boo!'})
You can pass args, for example:
happy.call('very much')
arguments work just as you expected in blocks:
Proc.new {|amount| puts "yay #{amount} !"}
daf
source share