Hacker News new | ask | show | jobs
by sapphirecat 5294 days ago
+= does union-by-key: any keys present in the right array, and not in the left, are appended to the left.

`array_merge` will append all numeric keys from the right array to the left, under new key values, as if you used [] one-by-one; for string keys, all keys from the right are copied into the left, possibly overwriting what was there.

In real code, I either have all-numeric or all-string keys, and `array_merge` does what I want in bulk operations: it's essentially equal to Python list.extend and dict.update, respectively. `+` on arrays is basically useless for me.