Proposal: Pipe End operator |>>

Having worked a bit with Clojure’s threading operators -> and ->> I find that sometimes I’d like a pipe end operator like Clojure’s ->> operator. What this would do is pass the piped value at the end of the parameter
list rather than the beginning. I’ve seen code that overcomes this shortcoming like this

|> &(do_something(var, &1)).()

Instead it would be nice if we could instead do:

|>> do_something(var)

Sorry if this has been suggested before.

Supports piping to any location.

1 Like

It gets suggested every 6 months or so. Unless this brings something new to those discussions I’m probably going to suggest we lock the thread so we can avoid just having the same conversation again.


It’s also not too complicated to replace it with

|> fn x -> your_func(a, b, x) end.()
1 Like

The general answer here is to not pipe to anonymous functions at all, but create a defp named function that does the swap. This is almost always superior because names are rarely bidirectional. IE most function names don’t read as well if the order of the arguments is switched, so writing a defp gives you the opportunity to reword things properly.


I figured that would be the case. The fact that it keeps coming up may mean it’s worth considering. :grinning:

But I’m fine with locking the thread and letting it go.