News for hackers. Stuff that matters.
Re:Go(lang): Robust generic functions on slices by __s on Saturday February 24, 2024 @07:47AM (#39491116)
By returning nil, the function makes it clear that it doesn't move the input reference
Re:Go(lang): Robust generic functions on slices by stouset on Saturday February 24, 2024 @04:28PM (#39495283)
Yes, but now I have to keep track of which functions invalidate-and-return and which return nil. If I forget that `slices.Delete` returns a new slice instead of mutating in-place, the language doesn’t help me.