On Thu, 8 Feb 2007, Micah Wylde wrote:

> I'm not a contributor, but I am a user of ruby, and there is a
> possibility that no one seems to have mentioned. What about having
> String.ord return an array of integers, with a one character string
> returning a one element array?
>
> So "test".ord => [116, 101, 115, 116]
> "a".org => [97]
>
I must disagree with you. This would make things even slower.
Usualy you use String::ord to get value of one specified char.
String::ord(index) sounds best from all propositions Ive seens here.
Its elegant anf fast.
Also.. if you want such behavior.. I think it would be better to provide
range functionality to ord aswell
"test".ord -> 116
"test".ord(1) -> 101
"test".ord(1..2) -> [101,115]

What Do you think guys about that?

> Under this scheme, referencing a particular number is no more
> difficult then it is now, just instead of "test"[2].ord, you'd do
> "test".ord[2]. The biggest disadvantage I can see is the requirement
> for creating the array, which for big strings could get expensive.
> However, if the user is worried about that they can just do
> "test"[2].ord[0], which would be significantly less expensive (though
> slightly more than the current scheme).
>
> I agree that there shouldn't be methods that only work with certain
> strings. That, I think, just causes confusion and goes against the
> object-oriented principles of ruby.
>
> -- 
> Micah Wylde
>
>