logankilpatrick
logankilpatrick

Reputation: 14501

What does the syntax "|>" do in Julia?

I am looking at someone's code that has "|>" in it. What does that syntax do in Julia and can someone link the Julia Docs for it?

Upvotes: 4

Views: 414

Answers (1)

Commonly denoted as "pipe syntax", this syntax:

Applies a function to the preceding argument. This allows for easy function chaining.

An example from the official docs:

julia> [1:5;] |> x->x.^2 |> sum |> inv

0.01818181818181818

And the official Julia docs page where you can find the |> operator is here.

Upvotes: 6

Related Questions