From: "Ara.T.Howard" Date: 2004-02-14T00:54:55+09:00 Subject: Re: return from yielded block On Fri, 13 Feb 2004 nobu.nokada@softhome.net wrote: > Date: Fri, 13 Feb 2004 15:08:34 +0900 > From: nobu.nokada@softhome.net > Newsgroups: comp.lang.ruby > Subject: Re: return from yielded block > > Hi, > > At Fri, 13 Feb 2004 14:54:56 +0900, > Ara.T.Howard wrote in [ruby-talk:92771]: > > the problem is that you can't 'return' from a block - so how is this done? > > Return to where? The next statement of yield? > If so, you may want "next". return a value. i was not clear enough, let me try again: def meth s x = block_meth do if s =~ /forty/ return 40 else return 0 end end x + 2 end def block_meth; yield; end p(meth('forty')) # this prints 40 - i want it to print 42 -a