-
I'm looking for an equivalent of argument "unpacking" in Python, i.e.:
So far the solution I've come up with is like this:
Is there a more idiomatic way of achieving the same? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
I don't think there's a more idiomatic way to do this currently. In the Nix world, it's common to take a record as an argument and destructure it in the function, to emulate named parameters:
This provides some structure, and the ability to build and pass one structured argument . But nothing like this for arrays and positional arguments. If you need this repeatedly, the best you can do is probably to put this code in a helper function:
|
Beta Was this translation helpful? Give feedback.
I don't think there's a more idiomatic way to do this currently. In the Nix world, it's common to take a record as an argument and destructure it in the function, to emulate named parameters:
This provides some structure, and the ability to build and pass one structured argument . But nothing like this for arrays and positional arguments. If you need this repeatedly, the best you can do is probably to put this code in a helper function: