[#300] Ruby 1.3.3-990507 — matz <matz@...>
Ruby 1.3.3-990507 is out, check out:
1 message
1999/05/07
[#314] Arity features for Proc object? — matz@... (Yukihiro Matsumoto)
A mail from <yeboah@tu-harburg.de> is somehow rejected by the list
12 messages
1999/05/17
[#315] Re: Arity features for Proc object?
— matz@... (Yukihiro Matsumoto)
1999/05/17
[#316] Re: Arity features for Proc object?
— gotoken@... (GOTO Kentaro)
1999/05/17
In message "[ruby-talk:00315] Re: Arity features for Proc object?"
[#318] Re: Arity features for Proc object?
— matz@... (Yukihiro Matsumoto)
1999/05/17
Hi.
[#319] Re: Arity features for Proc object?
— gotoken@... (GOTO Kentaro)
1999/05/17
In message "[ruby-talk:00318] Re: Arity features for Proc object?"
[#320] Re: Arity features for Proc object?
— matz@... (Yukihiro Matsumoto)
1999/05/17
Hi.
[#323] binding — Pros Yeboah <yeboah@...>
Hi
5 messages
1999/05/18
[#357] thinking aloud — "Bryce Dooley" <thecrow@...>
First off, I think Ruby is a very nice scripting language.
7 messages
1999/05/29
[ruby-talk:00311] Re: help: iterator..
From:
matz@... (Yukihiro Matsumoto)
Date:
1999-05-14 07:16:50 UTC
List:
ruby-talk #311
Hi.
In message "[ruby-talk:00310] help: iterator.."
on 99/05/14, Pros Yeboah <yeboah@tu-harburg.de> writes:
|How do one pass the one pass the block of an iterator recursively
|further.
|eg.
|def foo(bar)
|if bar <= 0; "baz"
| else foo(bar-=1) ???? # ??? ==> the passed iterator block
|end
|end
|
|foo is supposed to be called with foo(something){block}.
Hmm, there are two ways to accomplish this.
(a) use tha passing block, like
foo(bar-1) {|x| yield x}
(b) use block argument to pass block.
def foo(bar, &block)
...
foo(bar-1,&block)
...
end
The former is pretty ugly, but runs bit faster. The latter is simpler
but creation of the Proc object make it slower.
|1) I don't want to use a Proc Object as a parameter.
The second one objectifies the block into the Proc object, so it may
not sufisfy you.
|2) How can one refer to the object for the iterator block ?
The block can be objectified by either:
* calling lambda or proc or Proc.new without block within the iterator.
* declaring block argument as formal argument of the method.
Hope this helps you (and others).
matz.