From: Dossy Date: 2002-07-06T02:11:01+09:00 Subject: Re: is there a better string.each? On 2002.07.06, Marko Schulz wrote: > On Fri, Jul 05, 2002 at 02:29:44PM +0900, Tom Sawyer wrote: > > > > if it smells like a fish, and looks like a fish, and tastes like a > > fish.... > > > > they fact of the matter is: a string is an ordered set of characters and > > an an array is an ordered set of objects. thus the array is the general > > data structure. a string is a subset of array in that it is the same > > type of data structure but limited to characters (which i think is an > > object type that is lacking in ruby), yet a string is also a superset of > > array in that it has many additional methods. > > > > in effect i could design a string class that inherits array: > > > > class String < Array > > > > and i think that's how it a ought to be done. > > This works fine for German and English Strings. Does this uphold for > other languages too? No. Not for Japanese, Chinese, Korean, Russian, (I think) Hebrew ... Well, maybe. I can't think of a language where a string isn't a set of characters _in that language_, however, when you're talking about a computer representation, a string is a sequence of characters but a "character" in the alphabet can also be a sequence of bytes itself. A String might appear at first to be derived from Array, but a String is really an Array of Characters, where a Character might itself be an Array of Bytes. Then, you begin to untangle the holy mess that a single String has created with regard to the number of Objects that is required to represent it. IMHO, that's some serious foul stuff. -- Dossy -- Dossy Shiobara mail: dossy@panoptic.com Panoptic Computer Network web: http://www.panoptic.com/ "He realized the fastest way to change is to laugh at your own folly -- then you can let go and quickly move on." (p. 70)