Yukihiro Matsumoto
12/25/2006 7:09:00 PM
Hi,
In message "Re: Strange about Array#each_index"
on Tue, 26 Dec 2006 03:51:19 +0900, Li Chen <chen_li3@yahoo.com> writes:
|I query Ruby about Array#each_index and here are what Ruby returns:
|
|--------------------------------------------------- Array#each_index
| array.each_index {|index| block } -> array
|--------------------------------------------------------------------
| Same as +Array#each+, but passes the index of the element instead
| of the element itself.
|C:\>irb
|irb(main):001:0> a = [ "a", "b", "c" ]
|=> ["a", "b", "c"]
|irb(main):002:0> a.each_index {|x| print x, " -- " }
|0 -- 1 -- 2 -- => ["a", "b", "c"]
|irb(main):003:0>
each_index returns the receiver, and irb prints the return value.
matz.