From: Dave Oshel Date: 2003-05-26T10:37:15+09:00 Subject: Re: why is "does" missing from this sub!-stitution? In article , dblack@superlink.net wrote: > Hi -- > > On Sat, 24 May 2003, Dave Thomas wrote: > > > dblack@superlink.net wrote: > > > > > I'm with you on the 'what', but I'm still curious about the 'why'. > > > It's true that the replacement string gets parsed before sub is > > > called. But I think "abcdef" gets matched against the regex even > > > before that parse happens. > > > > > > But it doesn't. Think about it this way > > > > def fred(a, b) > > $x = 1 > > puts a > > puts b > > end > > > > $x = 99 > > fred(11, $x) > > fred(11, $x) > > > > #=> > > 11 > > 99 > > 11 > > 1 > > > > The parameters to a method are evaluated at the point of call: the > > method can't affect the value of its parameters. > > I'm hip to this part (see ruby-talk:70238 for proof :-) It's the \1 > thing that I've managed to garble. I've been thinking: if $1 hasn't > been reassigned yet, then how can \1 mean anything? But the answer, I > now see, is: it means \1, which gets passed literally to the method, > which *then* knows what to do with it. > Ok, I sort of understand that. But the corresponding Perl syntax seems more obvious, to my aching head. Is there a Ruby gotchas page, somewhere on the web? -- ["10110100101101000101000000100010100001100110111010010110001001100000010011000010011101000000010011110010110011100001011010100110001101101001000010010000001001101100011011110110110011100001011010100110001101100000001010110110100001101100011001110100110001101111011010110110010100001100001010100110001001101000011001001110000001000100101010000110000011101001011000100110110011100011010000000100100100101000001010010000000101100010111000101110000011100101110011110100111101000001011011110110101101101010011000001110100001101110011010100110011101001011011010000110110001100111010011000110111101101011011011110100001001101100011011110110110011100001011010100110001101101111010001010000010001001001101010100110001011100000010010000010011101101111011000101110000101101010011001001110000001000100101010101110010001101001111000000100000100101000011011000110110101101010011001001110"].pack("b*")