[#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:02097] Re: Array Gotchas

From: OZAWA Sakuro <crouton@...>
Date: 2000-03-23 03:25:33 UTC
List: ruby-talk #2097
In article <200003230244.LAA07577@hanare00.math.sci.hokudai.ac.jp>,
    GOTO Kentaro writes:

> >Ruby> ary = [1, 2, 3, 4, 5]
> >Ruby> ary.each_index {|i| print i, "\n"}

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

In addition, bcause array indice have range from 0 to size-1,

ary.each_index {|i| print i, "\n"}

will print values from 0 to (ary.size - 1).
                            ^^^^^^^^^^^^^^
While

(0..ary.size).each {|i| print i, "\n"}

will print values from 0 to ary.size.

-- 
OZAWA -Crouton- Sakuro
<mailto:crouton@duelists.org> <http://www.duelists.org/~crouton/>
PGP Fingerprint: C98F 74E0 AEEB 4578 1DFC  F650 3BE0 9627 11FC C9F5

In This Thread

Prev Next