S
Simon Mullis
Hi All,
Question re Array method += and
And
But
(irb):28: syntax error, unexpected tOP_ASGN, expecting $end
( a ||= [] ) += [ 1, 2, 3, 4 ]
^
from (irb):28
Why?
I guess it's a precedence issue. '<<' is a method in the Array class.
'+=' is not.
Is there alternate syntax I should use?
Thanks
SM
Question re Array method += and
=> [1, 2, 3, 4]a = [] => []
a += [1, 2, 3, 4]
And
=> [[1, 2, 3, 4]](a ||= []) << [1, 2, 3, 4]
But
SyntaxError: compile error( a ||= [] ) += [ 1, 2, 3, 4 ]
(irb):28: syntax error, unexpected tOP_ASGN, expecting $end
( a ||= [] ) += [ 1, 2, 3, 4 ]
^
from (irb):28
Why?
I guess it's a precedence issue. '<<' is a method in the Array class.
'+=' is not.
Is there alternate syntax I should use?
Thanks
SM