T
Tj Holowaychuk
In Ruby < 1.9 what does this really do? For example I wrote
class String
def tokenize! hash
hash.inject(self) { |s, (k, v)| s.gsub! /:#{k}/, v }
end
end
Which has a usage of:
'Welcome :name, enjoy your bject'.tokenize!({ :name => 'TJ', bject
=> 'cookie' })
anyways, the inject did not work as desired until I put parens around
the last two parameters, yet I do not entirely understand whats going
here! does this just cause the distribution of the variables to change?
class String
def tokenize! hash
hash.inject(self) { |s, (k, v)| s.gsub! /:#{k}/, v }
end
end
Which has a usage of:
'Welcome :name, enjoy your bject'.tokenize!({ :name => 'TJ', bject
=> 'cookie' })
anyways, the inject did not work as desired until I put parens around
the last two parameters, yet I do not entirely understand whats going
here! does this just cause the distribution of the variables to change?