A developer opinion piece arguing that functions which mutate state should return the modified value rather than operating purely in-place. Uses Python's `random.shuffle()` as the primary example of a flawed design — it mutates a list without returning anything, making it easy to misuse. The author acknowledges the counterargument about memory efficiency for large objects but maintains that functions altering an entire variable's contents should return a new value. Mentions a personal side project (`listo`) created to scratch this itch.

2m read timeFrom daniel.feldroy.com
Post cover image
Table of contents
CounterargumentClosing statement

Sort: