December 2018
Beginner to intermediate
500 pages
12h 10m
English
Reading multiple nested functions can be taxing on the brain. The previous example, collect(keys(attrs(dom.root))), can be rewritten to improve readability using Julia's pipe operator, |>.
For example, the following snippet nests three function calls, each inner function becoming the argument of the outermost one:
julia> collect(keys(attrs(dom.root)))
3-element Array{AbstractString,1}:
"class"
"lang"
"dir"
This can be rewritten for improved readability as a chain of functions using the pipe operator. This code produces the exact same result:
julia> dom.root |> attrs |> keys |> collect
3-element Array{AbstractString,1}:
"class"
"lang"
"dir"
What the |> operator does is that it takes the output of the first value and pipes ...
Read now
Unlock full access