Ruby 1.9.2 リファレンスマニュアル > ライブラリ一覧 > primeライブラリ > Prime::PseudoPrimeGeneratorクラス > each_with_index
with_index {|prime, index| ... } -> selfeach_with_index {|prime, index| ... } -> selfwith_index -> Enumeratoreach_with_index -> Enumerator与えられたブロックに対して、素数を0起点の連番を渡して評価します。
例:
Prime::EratosthenesGenerator.new(10).each_with_index do |prime, index| p [prime, index] end # [2, 0] # [3, 1] # [5, 2] # [7, 3]
[SEE_ALSO] Enumerator#with_index