[#1816] Ruby 1.5.3 under Tru64 (Alpha)? — Clemens Hintze <clemens.hintze@...>

Hi all,

17 messages 2000/03/14

[#1989] English Ruby/Gtk Tutorial? — schneik@...

18 messages 2000/03/17

[#2241] setter() for local variables — ts <decoux@...>

18 messages 2000/03/29

[ruby-talk:02096] Re: Array Gotchas

From: gotoken@... (GOTO Kentaro)
Date: 2000-03-23 02:44:34 UTC
List: ruby-talk #2096
In message "[ruby-talk:02093] Re: Array Gotchas"
    on 00/03/22, "Dat Nguyen" <thucdat@hotmail.com> writes:
>Following was my exercise:
>
>Ruby> ary = [1, 2, 3, 4, 5]
>Ruby> ary.each_index {|i| print i, "\n"}
>0
>1
>2
>3
>4
>[1, 2, 3, 4, 5]
>Ruby> (0..ary.size).each {|i| print i, "\n"}
>0
>1
>2
>3
>4
>5
>0..5

I'm guessing you used eval.rb.  This difference is not in Ruby but in
eval.rb; eval.rb reports the value of each statement.

Generally speaking, A statement returns a value in Ruby. 
Each last output line is the value of the statement, i.e.,

[1, 2, 3, 4, 5] 
   is the value of `ary.each_index {|i| print i, "\n"}'
0..5
   is the value of `(0..ary.size).each {|i| print i, "\n"}'

-- gotoken
PS. Should I use irb instead of eval.rb in User's guide?

In This Thread