On Sunday 03 November 2002 6:12 am, Gavin Sinclair wrote: > From: "Albert Wagner" <alwagner / tcac.net> > > > > [Enric:] > > > Why are Strings arrays of integers ? aString[0] is an integer, yes, > > > it's the way it is, but I would like to have String as an array of > > > chars, and char if you want as a descendant of Integer (nice election > > > because a Unicode String is and array of double chars i.e. integer), I > > > don't know you, but for me aString[i].chr =='x' is somewhat unnatural, > > > because it breaks the semantic of a String, so it's not intuitive for > > > me. > > > > It is not intuitive to many people. There have been long discussions on > > the pros and cons. > > It's probably not intuitive to *anybody* (except perhaps Matz). However, I > see no particular justification for it being any other way, and in fact > it's changing in 1.7 isn't it? Anyway, my point is: you'll never forget it > now. And if you're like me, you won't care either. > > But to nitpick, a String is *not* an array of integers. It is a String :) > > Other options, if you're testing equality of an individual character: > > string[i] == ?x > string[i,1] == "x" So that no one misunderstand my comments about Smalltalk. I don't mean to imply that I think Ruby is flawed to the extent that it is not Smalltalk. I am quite pragmatic about languages: I dislike intensely the image aspects of Smalltalk. I very much like "require", "include", et al in Ruby. > > Cheers, > Gavin -- "I invented the term Object-Oriented, and I can tell you I did not have C++ in mind." -Alan Kay