From: Andreas Warberg Date: 2008-05-30T21:18:21+09:00 Subject: Re: Proc multiple returns? Ryan Lewis wrote: > code: > def foo(&block) > block.call if block > end > > p foo { > "bar" > "baz" > } > > => "baz" > > Now, any ideas on how to make it return > => ["bar", "baz"] How about: irb(main):010:0> def foo(&block); block.call if block; end => nil irb(main):011:0> foo { ["bar", "baz"]} => ["bar", "baz"] irb(main):012:0> And you could explode it to multiple variables like this: irb(main):021:0> a,b = *foo { ["bar", "baz"]} => ["bar", "baz"] irb(main):022:0> a => "bar" irb(main):023:0> b => "baz" irb(main):024:0> Andreas -- Posted via http://www.ruby-forum.com/.