From: "David A. Black" Date: 2008-05-30T20:38:06+09:00 Subject: Re: Proc multiple returns? On Fri, 30 May 2008, David A. Black wrote: > Hi -- > > On Fri, 30 May 2008, 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"] >> >> I've been tryin all night -_- > > def foo > yield if block_given? # no point doing it the slow way :-) > end > > p foo { ["bar", "baz"] } > > I have a feeling there may be something more to your question that I'm > not seeing. Maybe this: foo { break "bar", "baz" } ? David -- Rails training from David A. Black and Ruby Power and Light: INTRO TO RAILS June 9-12 Berlin ADVANCING WITH RAILS June 16-19 Berlin See http://www.rubypal.com for details and updates!