From: Phrogz Date: 2006-12-27T13:15:06+09:00 Subject: Re: Peculiar Behavior for a Newby to Undertstand Rob Biedenharn wrote: > The value of the #step method is the initial value so that is being > returned from a.show_primes and presumably printed by whatever you're > using to interpret your statements (like irb): As a simple example: irb(main):001:0> puts 1.step( 2 ){ print "a " } a a 1 => nil In the above, the block is called twice, and prints out 'a ' each time. Then the return value of the step method (the initial value) it passed to the puts function, which prints it out. You're seeing your first non-even value as the return, since the step method is the last call in your show_primes method. One other comment - the pairing of methods you have inside your class seems odd, given Ruby's built-in classes for numbers. Instead of your class wrapper, I might personally place those methods as: class Integer def is_prime? # ... end end def show_primes( lower, upper ) end Although, since I'm personally not a big fan of 'global' functions, I might even do: class Integer def self.show_primes( lower, upper ) # ... end end