4 ms·
If only you could pattern match x in the function def, would remove the need for this whole thing.
by thejosh 9y ago
If only you could pattern match x in the function def, would remove the need for this whole thing.
- wruza 9y agoAside from compile-time optimization, pattern matching is just this additional if at runtime. It is questionable if pattern matches make code more readable since when you see foo(42) call and def foo(42) is defined elsewhere, you can spend some time on original function until realizing that it’s not what you’re looking for. The same for type-based and operator overloading. It only makes code beautifu^W hard to guess. Though it does look nice for fib and fac.