From: Robert Klemme Date: 2009-04-30T20:11:51+09:00 Subject: Re: Random Access using IO#pos in code blocks 2009/4/30 Brian Candler : > Robert Klemme wrote: >> I do have to admit though that I >> do not know when the object is allocated (i.e. at time of match or >> when referencing $`). > > Experiment suggests the MatchData is created immediately on the match, > and the string is instantiated lazily from that. This makes sense; it > would be very inefficient to allocate strings for $`, $1, $2, $3, ... $' > when maybe none of them will be used. But the MatchData object has the > original string plus all the offsets. Ah, good to know! Thanks for the experimenting! "Tune in next week when you'll hear Dr. Brian say: what's this fuse for?" ;-) Kind regards robert -- remember.guy do |as, often| as.you_can - without end http://blog.rubybestpractices.com/