From: Florian Gross Date: 2005-03-24T05:34:54+09:00 Subject: Re: Iterating through a string and removing leading characters Randy Kramer wrote: > Thanks, but I'm still confused--s1 is "This is a test", so 211 is neither nil > nor ASCII for "i", and besides, I asked for the (object_)id. > > 211 does happen to be 2*?i+1--maybe there's a clue there? (and the same thing > holds for the previous character (h) which shows up as 209) irb(main):001:0> ?i.id (irb):1: warning: Object#id will be deprecated; use Object#object_id => 211 This is consistent with the explanation from my earlier posting: 'So "foo"[0] == ?f. And the object_id of low Fixnums is usually very low as their value is directly stored in it.' > My original concern: I was hoping that s1[0] and similar did not create new > objects, and I suspect they don't, but I'm not sure. Fixnums are never created (they are only referred to) so this does not cause any object creation overhead.