P
Peña, Botp
Hi Ruby friends:
I can push thru an array fine:
irb(main):059:0> a
=> [["a", 2], ["b", 1], ["c", 3]]
irb(main):060:0> a << ["d",4]
=> [["a", 2], ["b", 1], ["c", 3], ["d", 4]]
cannot do it using hash.
irb(main):061:0> h
=> {"a"=>2, "b"=>1, "c"=>3}
irb(main):062:0> h << "d"=>4
SyntaxError: compile error
(irb):62: syntax error
irb(main):063:0> h << {"d"=>4}
NoMethodError: undefined method `<<' for {"a"=>2, "b"=>1, "c"=>3}:Hash
irb(main):064:0> h << ("d"=>4)
SyntaxError: compile error
(irb):64: syntax error
Is there a reason why "<<" isn't allowed for hashes?
kind regards -botp
I can push thru an array fine:
irb(main):059:0> a
=> [["a", 2], ["b", 1], ["c", 3]]
irb(main):060:0> a << ["d",4]
=> [["a", 2], ["b", 1], ["c", 3], ["d", 4]]
cannot do it using hash.
irb(main):061:0> h
=> {"a"=>2, "b"=>1, "c"=>3}
irb(main):062:0> h << "d"=>4
SyntaxError: compile error
(irb):62: syntax error
irb(main):063:0> h << {"d"=>4}
NoMethodError: undefined method `<<' for {"a"=>2, "b"=>1, "c"=>3}:Hash
irb(main):064:0> h << ("d"=>4)
SyntaxError: compile error
(irb):64: syntax error
Is there a reason why "<<" isn't allowed for hashes?
kind regards -botp