top | item 26223240

(no title)

val_deleplace | 5 years ago

I agree with the 2 example tasks, which are not "simple" to write.

The remove-by-value snippet is 8 lines, and it can be wrong in a subtle way: if list contains pointers, then we have a memory leak beyond the slice final length (pointer values still exists within capacity, and objects are not garbage collected).

I wrote several possible implementations here, none of which is as concise and as obviously correct as an hypothetical "list.remove(v)": https://programming-idioms.org/idiom/136/remove-all-occurren...

discuss

order

No comments yet.