L
Luke Ivers
I'm not 100% how exactly to search to find out if someone else has posed
this question, but why does the following happen?
Given:
class Hash
def << (key, val=nil)
self.store(key, val)
end
end
h = {}
h << 'test'
h << 'test', 'bob'
Gives back:
test.rb:9: parse error, unexpected ',', expecting $
h << 'test', 'bob'
If I change the last line to:
h << ('test', 'bob')
I get back:
test.rb:9: parse error, unexpected ',', expecting ')'
h << ('test', 'bob')
this question, but why does the following happen?
Given:
class Hash
def << (key, val=nil)
self.store(key, val)
end
end
h = {}
h << 'test'
h << 'test', 'bob'
Gives back:
test.rb:9: parse error, unexpected ',', expecting $
h << 'test', 'bob'
If I change the last line to:
h << ('test', 'bob')
I get back:
test.rb:9: parse error, unexpected ',', expecting ')'
h << ('test', 'bob')