From: Josh Cheek Date: 2010-04-03T09:29:26+09:00 Subject: Re: return number of spaces at the beginning of a line --000e0cd104f4dc58ab04834a2fd4 Content-Type: text/plain; charset=ISO-8859-1 On Wed, Mar 31, 2010 at 12:11 PM, Aldric Giacomoni wrote: > Josh Cheek wrote: > > On Tue, Mar 30, 2010 at 9:35 AM, Robert Klemme > > wrote: > > > >> And it has the disadvantage over str[/\A */].length that likely is > >> slower because of the alternative. > >> > > There was a blog by Yehuda Katz that implied to me that these globals > > weren't set until you asked for them, > > No, they are created as soon as the regular expression is parsed. I > believe Wycats explained that somewhere else, but I can't find the link > at the moment. > -- > Posted via http://www.ruby-forum.com/. > > I was reading Rick DeNatale's blog Talk Like A Duck which directed me to a different post of Yehuda Katz's, where I found a more explicit explanation: "When you use =~, there is no actual MatchData object, $1 just behaves like it was indexing into an implicit MatchData" http://yehudakatz.com/2010/02/21/ruby-is-not-a-callable-oriented-language/ He doesn't say anything about $&, but I'd be surprised if it wasn't the same. Though a quick survey of the pickaxe and The Ruby Programming Language didn't imply this implementation detail. --000e0cd104f4dc58ab04834a2fd4--