Hi,
In message "[ruby-talk:4816] Re: Some questions"
on 00/09/07, Friedrich Dominicus <frido / q-software-solutions.com> writes:
|> Because String is not a indexed container. You can use
|> each_with_index instead.
|
|aren't Strings just Arrays? I have looked into the functions of the
|class and among them is self[nth] etc.. The same is there for Arrays
No. Of course, String and Array share many method as sequences. But
they are not identical. String is a two face class. A sequence of
characters, and a sequence of lines. Some like [] etc. works on
characters. OTOH, each, sort, etc. works on lines.
Then, what do you think each_index should work on?
Characters? Lines?
Either case, somebody suppose the other one, and get confused.
I think each_index for String is merely a source of confusion.
This is the reason why there's no each_index in String.
Did I explain properly?
matz.