is there a possibility to match in a function definition do some subset of a touple and still get get complete touple in the method ?
What I would like to do is something like this:
myfun({ foo, Bar }: Var) -> otherfunction(Var, stuff).
instead of:
myfun({ foo, Bar }) -> otherfunction({ foo, Bar }, stuff).
I hope this is clear enough.
Thanks.
You can ignore some parameters by putting an underscore in front. E.g.
myfun( {foo, _Bar, Var } )
will match by ignoring the _Bar parameter. Is that what you had in mind?
Or did you mean:
myfun( {foo, Bar} = Var ) -> otherfun( Var ).
in this case, Var will be used in otherfun iff the match with myfun succeeded. The reason is: Var is un-bound at the time of evaluation of the expression and thus will be assigned to {foo, Bar}.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With