End of Life Ruby 3.0 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →
instance method
Prime::PseudoPrimeGenerator#with_index
with_index(offset = 0) { |prime, offset| ... }
lib/prime.rb
View on GitHub ↗
# File tmp/rubies/ruby-3.0.5/lib/prime.rb, line 384
def with_index(offset = 0, &block)
return enum_for(:with_index, offset) { Float::INFINITY } unless block
return each_with_index(&block) if offset == 0
each do |prime|
yield prime, offset
offset += 1
end
end
see Enumeratorwith_index.