[ruby-talk:02392] Re: Iterator into array

From: matz@... (Yukihiro Matsumoto)
Date: 2000-04-08 03:15:24 UTC
List: ruby-talk #2392
Hi,

In message "[ruby-talk:02389] Re: Iterator into array"
    on 00/04/07, Dave Thomas <Dave@thomases.com> writes:

|My suggestion (actually, it's less than a suggestion, it's really just a 
|wild idea) is that the values passed to 'yield' could be collected in
|to an array in the cases where an iterator was called without a
|block. In this case, the values passed to yield (the Fibonacci numbers 
|in this case) would be collected, so the method would return an array
|of them.

I don't think it's possible, since some methods work both with and
without blocks, e.g. sort, gsub, etc.

| In another post, I suggested a disambiguation in the calling
|syntax to make this possible without breaking other code.

I feel "method*(...)" is, being honest, ugly. :-)

It's still possible to introduce a new syntax for collecting yielded
values, but we should not in a hurry to change the syntax.

							matz.

In This Thread