Pass code block into each : Prime Numbers « Number « Ruby






Pass code block into each


require 'mathn'
primes = Prime.new

primes.each { |x| puts x; break if x > 15; }
# 5
# 7
# 11
# 13
# 17
primes.succ                                     # => 19

 








Related examples in the same category

1.Prime Numbers
2.Use Prime to generate prime numbers
3.Generates 25 prime numbers from 2 to 97
4.Use each method from Prime class
5.Generating Prime Numbers with succ