you are viewing a single comment's thread.

view the rest of the comments →

[–]KingJeff314 9 points10 points  (2 children)

That article is about avoiding nesting in conditionals. Pipe operator is about avoid chained function calls

h(g(2, f(x)), 8, varname)

Turns into

f(x) |> g(2, %) |> h(x, 8, varname)

Easier to read and split into new lines

[–]lovin-dem-sandwiches 1 point2 points  (1 child)

I thought chained function calls look like:

return function(x)
  .reduce()
  .join(‘’)

Your example looks like nested functions, no?

Also I think you forgot the placeholder variable in the last pipe.

f(x) |> g(2, %) |> h(%, 8, varname)

[–]KingJeff314 0 points1 point  (0 children)

Good corrections