3 ms·
in kotlin, named parameters are a good defense against this. They help in many cases. Mixing named and default parameters in a method, modifying an API without
by on_and_off 7y ago
in kotlin, named parameters are a good defense against this.
They help in many cases. Mixing named and default parameters in a method, modifying an API without breaking its usage, etc.
It is slightly more verbose, but I tend to use them a lot. Basically everywhere unless the params are obvious (max(a;b) is a good example)
- thaumasiotes 7y ago> Basically everywhere unless the params are obvious (max(a;b) is a good example) This isn't so much "obvious" as "irrelevant"; the arguments to max are all exactly equivalent -- their order can't affect the result.
- thaumasiotes 7y agoExpanding on the point a little further, it would be normal from certain mathematical perspectives to see max as a unary function, mapping an unordered (multi)set to the set's maximum element. With one argument, order can't matter because only one order is possible.