Hacker News new | ask | show | jobs
by jzwinck 2209 days ago
An even more concise form is built in, and I think more obvious to readers:

    v.insert(v.end(), { 1, 2, 3, 4, 5 });
1 comments

I was actually not describing adding elements to a container, but adding up values.
See? That's the problem with arithmetic on containers. Python has that already:

    v += 4, 5, 6
Comma doesn't do weird shit: that's just a tuple of numbers. But "+=" then does weird shit: it means concatenation when v is a standard library list, and element-wise addition when v is a numpy vector.