Hi guys,
I see a lot of libraries try to allow piping to the first parameter by
default, but some don't support this easily.
I propose the following syntax to remedy this where it's needed to pipe to
a specific parameter:
1) Normal pipe clearly works the same:
%{} |> SomeCode.function(other_params) === SomeCode.function(%{},
other_params)
2) The number of > dictates the position of the function we want to pipe
into:
%{} |>> SomeCode.function("param1") === SomeCode.function("param1", %{})
3) We could also supply opts and other params:
%{} |>> SomeCode.function("param1", %{opts_are_param_3: true}) === SomeCode.
function("param1", %{}, %{opts_are_param_3: true})
4) We can move to any specific param we want with more arrows, maybe limit
it to 4, say to avoid it becoming ridiculous.
%{} |>>> SomeCode.function("param1", %{this_is_param_2: true}) === SomeCode.
function("param1", %{this_is_param_2: true}, %{})
Thoughts? Would other people find this useful in some situations?
--
You received this message because you are subscribed to the Google Groups
"elixir-lang-core" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elixir-lang-core/2f2e23c7-bbbc-4c20-b177-95dea8628752%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.