From: Just Another Victim of the Ambient Morality Date: 2008-12-24T05:11:23+09:00 Subject: Re: Integer.step is inclusive?! "Just Another Victim of the Ambient Morality" wrote in message news:xab4l.3997$9i5.3385@en-nntp-07.dc1.easynews.com... > I don't know how to post the output of irb so I'll just have to > describe it but if I run the following code: > > 0.upto(10){ |i| puts i } > > ...I will get 11 lines of output. This iterates eleven times. > Really?! > Why it does this is obvious. Integer.upto is inclusive so it includes > both 0 and 10. However, am I the only one who thinks this is strange > behaviour? I mean, the ususal programming protocol is that the last > element is not included (half-open sets, if you will) so the number of > iterations is the difference between numbers. > Why did Ruby turn out this way? Thank you... D'oh! ...and by ".upto" I, of course, meant ".step" !