Skip to content

Commit 56def41

Browse files
committed
Extend documentation for Base.splat
1 parent bdb04c3 commit 56def41

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

base/operators.jl

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,14 +1257,14 @@ string(s::Splat) = string("splat(", s.f, ')')
12571257
"""
12581258
splat(f)
12591259
1260-
Defined as
1260+
Equivalent to
12611261
```julia
1262-
splat(f) = args->f(args...)
1262+
my_splat(f) = args->f(args...)
12631263
```
12641264
i.e. given a function returns a new function that takes one argument and splats
12651265
its argument into the original function. This is useful as an adaptor to pass
12661266
a multi-argument function in a context that expects a single argument, but
1267-
passes a tuple as that single argument.
1267+
passes a tuple as that single argument. Additionally has pretty printing.
12681268
12691269
# Example usage:
12701270
```jldoctest
@@ -1273,6 +1273,12 @@ julia> map(Base.splat(+), zip(1:3,4:6))
12731273
5
12741274
7
12751275
9
1276+
1277+
julia> my_add = Base.splat(+)
1278+
splat(+)
1279+
1280+
julia> my_add((1,2,3))
1281+
6
12761282
```
12771283
"""
12781284
splat(f) = Splat(f)

0 commit comments

Comments
 (0)