From: zuzu Date: 2004-10-18T21:39:40+09:00 Subject: Re: DID YOU KNOW? -- break can return a value? On Mon, 18 Oct 2004 11:49:23 +0900, Dave Burt wrote: > "trans. (T. Onoma)" wrote... > > An interesting tidbit I pickup today. Did you know that break can return a > > value from it's block? > > > > a = loop do > > break (1 + 1) > > end > > > > puts a #=> 4 > > > > What platform gives that counterintuitive result? *grins* by defining the variable "a" with code "loop", it is a Proc object, yes? (sorry, i would test this myself except i'm away from my ruby console.) (if so, i must simultaneously pronounce my dislike for imperative loop structures, and my praise for ruby perceiving all code as in blocks / procedures (functional/subroutine style).) also, quite right dave, what gives with the "trailing off the edge of a procedure 'return' " producing a "value" of 4? perhaps that's the point; what exactly is going on when passing arguments into the break function/keyword? peace, -z