From: Robert Klemme Date: 2005-03-25T21:04:47+09:00 Subject: Re: Iterating through a string and removing leading characters "Randy Kramer" schrieb im Newsbeitrag news:200503241403.52395.rhkramer@gmail.com... > Well, maybe I'd better recap for myself (correct me if I'm still off > base): > > * (from earlier emails) Something like s1[start, length] (which I > misunderstood earlier to be s1[start, end]) doesn't just let you look at a > portion (substring) of the original string, but actually creates a new > (sub)string (with all the overhead of creating a new string). Correct. > * on the other hand, s1[index] does not create a new (one byte) string, > but > simply returns a Fixnum (which happens to be an object) representing the > ASCII value of the character. In other words, this has none of the > overhead > of creating a new string. Correct. > (I guess this is where I'm still a little > uncertain--does it go through some of the overhead of creating a new > string, No. > but the resultant new (one byte) strings all have the same value (the > ASCII It's not a new string but simply a Fixnum; in other languages it would be a Character instance - if there was a specialized class / type for this. > code for "i" which is Fixnum 105 of which (see next item) there is only > one, > which has object_id 211? Right. > Does it really matter to me? Not really, athough understanding the performance effects and other pecularities of Fixnum can be useful at times. > Probably not, maybe > it's just idle curiosity.) .... which aids us in learning new things - so it's not too bad to have. (Only cats suffer more often than is good for them from curiosity induced negative effects...) > * when I do an object_id on that Fixnum, I always get the same value > (211 > for 105 (the Fixnum which represents "i")) because there is only one > Fixnum > object in the system with the value 105. Correct. > I don't need a response to my "idle curiosity" question under the 2nd > bullet > if the rest of my understanding is basicly (sp?) correct. "sp?"? Happy Easter robert