From: Brian Candler Date: 2007-04-24T04:37:06+09:00 Subject: Re: Question regarding design of the String Class On Tue, Apr 24, 2007 at 02:40:09AM +0900, Michael W. Ryder wrote: > I guess my point was that str[i] behaves totally different from all the > other implementations of []. All of the others return a string. You clearly know a lot of languages then :-) As pointed out before, in C, str[i] is an expression whose value is an integer for the character at position i, exactly as in Ruby. In Perl, it doesn't do what you expect either: $ perl -e '$a = "abcde"; print $a[2], "\n";' $ (what this actually does is extract an element from the array @a, which I have not initialised, and is completely unrelated to the scalar $a) > In Business Basic or C if I want the numeric value of a character in a > string I specify that. Likewise if I want to copy a string from an > arbitrary position I don't have to specify an ending character like > Ruby. I just find s = t[i, -1] to be much harder to understand in a > quick read then s = t[i]. Others may not have this problem. Personally I would be *very* surprised if str[i] returned all the characters from 'i' to the end of the string. But then I don't program in Business Basic. I do program in C though. If I wanted the string from position i to the end of the string, I would write str + i, or possibly &str[i] In Perl you have to be explicit and call substr() Brian.