diff --git a/base/docs/helpdb.jl b/base/docs/helpdb.jl index 48e030f43b403..46b8106b54ff2 100644 --- a/base/docs/helpdb.jl +++ b/base/docs/helpdb.jl @@ -1538,8 +1538,9 @@ cconvert doc""" |>(x, f) + |>(x, y, ..., f) -Applies a function to the preceding argument. This allows for easy function chaining. +Applies a function to the preceding argument(s). This allows for easy function chaining. ```jldoctest julia> [1:5;] |> x->x.^2 |> sum |> inv diff --git a/base/operators.jl b/base/operators.jl index ad7e66213b9b3..b2639371bc011 100644 --- a/base/operators.jl +++ b/base/operators.jl @@ -196,6 +196,8 @@ copy(x::Union{Symbol,Number,AbstractString,Function,Tuple,LambdaStaticData, # function pipelining |>(x, f) = f(x) +|>(x, y, f) = f(x, y) +|>(args...) = args[end](args[1:end-1]...) # array shape rules diff --git a/test/operators.jl b/test/operators.jl index 6106afa1bd330..7b84437c108ce 100644 --- a/test/operators.jl +++ b/test/operators.jl @@ -48,6 +48,8 @@ p = 1=>:foo @test 1 .< 2 @test 1 .<= 2 +@test minmax(2,1)... |> tuple == (1,2) # test splicing in combination with pipelining + # issue #13144: max() with 4 or more array arguments let xs = [[i:i+4;] for i in 1:10] for n in 2:10