From: "r . h a r l o s" Date: 2002-01-31T12:25:07+09:00 Subject: Re: integer method question On Wed, 30 Jan 2002 22:08:15 -0500, Jim Menard wrote: > "r . h a r l o s" writes: > >> In irb, if I type: >> 2.upto(5) { |n| print n, "-" | } >> >> I expect to see: >> 2-3-4-5- >> >> but instead I see: >> 2-3-4-5-2 >> >> Why does the initial value get tacked onto the end? I'm running ruby >> 1.6.6 on Red Hat 7.2, irb version 0.7.4. > > You see the last "2" because after irb executes the code it prints the > value of the resulting object, in this case "2". > > On the command line, type "ruby -e '2.upto(5) { |n| print n, "-" | }" > and you will not see the final "2". Right you are, Jim. Thanks for the explanation! Richard -- Man's mind, once stretched by a new idea, never regains its original dimensions." --Oliver Wendell Holmes, Jr.