From: Tom Sawyer Date: 2002-07-05T14:29:44+09:00 Subject: Re: is there a better string.each? no way dude! 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. but there may very well be speed considerations, or Regexp considerations, or some such thing, for why it is not. although i find it odd since ruby is written in c. ruby did not fix the problem, it complexified matters in this regard. ~transami On Thu, 2002-07-04 at 20:27, Dossy wrote: > On 2002.07.05, Tom Sawyer wrote: > > a = "canada" > > a.each_byte do |i| > > puts i.chr > > end > > > > thought it was strange myself. personally i'd like it if String and > > Array where a little more in harmony. > > A String is a string. An Array is an array. Any coincidence that > a String is an array of characters doesn't mean that a String > converted to an Array should yield an array of characters. You > have String#split for that. > > > in c/c++ strings are arrays, arn't they? > > Thank goodness Ruby fixed this mistake. ;-) > > -- 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) > -- ~transami "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety." -- Benjamin Franklin