Pipes and broadcasts



The following does not work, is this a bug?

(3, 3) |> abs.

this one does work of course

(3, 3) |> x -> abs.(x)

but is a bit verbose.


No bugs here

(3, 3) .|> abs does work and abs.((3, 3)) is easier to read and shorter.


What you are trying to do doesn’t work because abs. does not exists. The . notation is a syntax sugar that gets translated to a broadcast call. You can inspect this.

julia> expand(:(abs.(x)))
:((Base.broadcast)(abs, x))


thanks, of course this is only a toy example, my applied case is a bit longer.


x |> fn. |> fn2. |> fn3. |> fn4.
etc etc is better than


I think |> should work with broadcasts