< :前の番号
^ :番号順リスト
> :次の番号
P :前の記事(スレッド移動)
N :次の記事(スレッド移動)
|<:前のスレッド
>|:次のスレッド
^ :返事先
_:自分への返事
>:同じ返事先を持つ記事(前)
<:同じ返事先を持つ記事(後)
---:分割してスレッド表示、再表示
| :分割して(縦)スレッド表示、再表示
~ :スレッドのフレーム消去
.:インデックス
..:インデックスのインデックス
Issue #5389 has been reported by Joey Zhou.
----------------------------------------
Feature #5389: New method Enumerator#iterate
http://redmine.ruby-lang.org/issues/5389
Author: Joey Zhou
Status: Open
Priority: Normal
Assignee:
Category:
Target version:
If we want to iterate over the elements of a enumerable object with *multiple* blocks, we can use the Enumerator class.
A method 'iterate' is required, we can write it in Ruby:
class Enumerator
def iterate
yield_value = self.next
return_value = yield yield_value
self.feed return_value
self
end
end
Well, here is an example:
array = (1..10).to_a
enum = array.map!
loop do
enum.iterate {|n| n + 10 }
enum.iterate {|n| n * 2 }
enum.iterate {|n| -n }
end
p array # => [11, 4, -3, 14, 10, -6, 17, 16, -9, 20]
We want to map an array: the 1st element use blk1, the 2nd use blk2, the 3rd use blk3...
I think this Enumerator#iterate method is sometimes useful, so would you please introduce it into the language core?
--
http://redmine.ruby-lang.org