From: Stefano Crocco Date: 2007-12-13T17:53:15+09:00 Subject: Re: Simple method and block. foo.times Alle giovedì 13 dicembre 2007, John Maclean ha scritto: > Why does the output stop at eight. Shouldn't the class of nine be > shown also? > > 9.times {|x| print x , " ", x.class, "\n" } > 0 Fixnum > 1 Fixnum > 2 Fixnum > 3 Fixnum > 4 Fixnum > 5 Fixnum > 6 Fixnum > 7 Fixnum > 8 Fixnum > => 9 No. From the ri documentation of Integer#times: int.times {|i| block } => int ------------------------------------------------------------------------ Iterates block int times, passing in values from zero to int - 1. This means that, in your case, it should call the blocks 9 times, from 0 to 8. If it also passed 9 to the block, it would make 10 iterations, not 9. If you want to include both 0 and 9, you can use upto instead of times: 0.upto(9){|x| puts "#{x} #{x.class}"} I hope this helps Stefano