On Sat, 14 Feb 2004 nobu.nokada / softhome.net wrote:

> Date: Sat, 14 Feb 2004 01:03:03 +0900
> From: nobu.nokada / softhome.net
> Newsgroups: comp.lang.ruby
> Subject: Re: return from yielded block
> 
> Hi,
> 
> At Sat, 14 Feb 2004 00:54:55 +0900,
> Ara.T.Howard wrote in [ruby-talk:92793]:
> > 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 
> 
> Use break or next instead of return.

thanks!  thought i tried that - guess not.  i like the look of

  break 40

but not

  next 40

are the semantics _exactly_ the same?

-a
-- 

ATTN: please update your address books with address below!

===============================================================================
| EMAIL   :: Ara [dot] T [dot] Howard [at] noaa [dot] gov
| PHONE   :: 303.497.6469
| ADDRESS :: E/GC2 325 Broadway, Boulder, CO 80305-3328
| STP     :: http://www.ngdc.noaa.gov/stp/
| NGDC    :: http://www.ngdc.noaa.gov/
| NESDIS  :: http://www.nesdis.noaa.gov/
| NOAA    :: http://www.noaa.gov/
| US DOC  :: http://www.commerce.gov/
|
| The difference between art and science is that science is what we
| understand well enough to explain to a computer.  
| Art is everything else.  
|   -- Donald Knuth, "Discover"
|
| /bin/sh -c 'for l in ruby perl;do $l -e "print \"\x3a\x2d\x29\x0a\"";done' 
===============================================================================