Hit this issue today and I think it's the problem with the bug highlighted in the Uber article too.
Problem is that append sometimes mutates the original array and sometimes doesn't.
Someone on HN said slice append has realloc semantics and that made a lot of sense.
If you pass a slice by value and append to it, the append may or may not modify the array pointed to by the original slice.
In the Uber example, it was clearly passing a slice by value into a function, and that function then called append on
No comments:
Post a Comment