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
···
On Mon, 18 Oct 2004 11:49:23 +0900, Dave Burt <burtdav@hotmail.com> wrote:
"trans. (T. Onoma)" <transami@runbox.com> 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*
Whatever it may be, I am quite sure 1 + 1 is still equal to 2.
···
On 2004-10-18 21:39:40 +0900, zuzu wrote:
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?
Yes, that's a typo, a would be 2, not 4. Strange how easy that is to
overlook!
T.
···
On Monday 18 October 2004 09:10 am, Florian Frank wrote:
On 2004-10-18 21:39:40 +0900, zuzu wrote:
> 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?
Whatever it may be, I am quite sure 1 + 1 is still equal to 2.
Well, he was right if we consider the additive group Z / 2 where 0 = 2
= 4... remember, you're not mistaken - you're clever.
~Me!
···
On Mon, 18 Oct 2004 22:40:27 +0900, trans. (T. Onoma) <transami@runbox.com> wrote:
On Monday 18 October 2004 09:10 am, Florian Frank wrote:
> On 2004-10-18 21:39:40 +0900, zuzu wrote:
> > 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?
>
> Whatever it may be, I am quite sure 1 + 1 is still equal to 2.
Yes, that's a typo, a would be 2, not 4. Strange how easy that is to
overlook!
T.
--
There's no word in the English language for what you do to a dead
thing to make it stop chasing you.