From: David Masover Date: 2010-05-14T04:34:36+09:00 Subject: Re: idiomatic way to pass multiple Procs/lambdas/blocks On Thursday, May 13, 2010 11:03:37 am Chuck Remes wrote: > Ruby doesn't allow for passing multiple blocks to a method so I'm faced > with passing Procs or methods. > > Is there a more idiomatic way to accomplish my intentions? Not really. In JavaScript, it'd look like this: send({ callback: function() { ... }, errback: function() { ... }, ... }); I'd suggest that route, actually, if you're going to have it just be a single method: # 1.9-only syntax send message, timeout: 123, callback: ->{...}, errback: ->{...} # 1.8 syntax send message, :timeout => 123, :callback => lambda{...}, :errback => lambda{...} I'd also suggest a convenience class built around it, so I can instead do: class Foo include YourModule def callback ... end def errback ... end end # Construct a new Foo and send a message with it Foo.send(some_message)