Actions
Feature #17353
openFunctional chaining operator
Feature #17353:
Functional chaining operator
Status:
Open
Assignee:
-
Target version:
-
Description
Since ruby already moving in that direction(functional), I would like to propose add to it OCaml-like chaining/pipe operator into ruby.
Which would allow such syntax
def handle(requests) = requests
|> Array.filter { not _1.from.user.banned? }
|> Array.map { _1 |> main_router.emit }
|> Array.each &awaiter
What exactly happens here ?
Let's look at a bit easier example:
Which is expands exactly to the code below
So what this operator does is nothing but just tricky form of AST building
Advantages:
- Increase readability
- It's more duck type-ish
Limitations:
- cant be overloaded
Actions