[ruby-core:93188] [Ruby trunk Feature#15799] pipeline operator
From:
shannonskipper@...
Date:
2019-06-16 15:29:45 UTC
List:
ruby-core #93188
Issue #15799 has been updated by shan (Shannon Skipper).
Seeing `|>` my assumption would be that you could use it in the functional style, so you could do:
``` ruby
42 |> Integer(exception: false) |> Math.sqrt
```
Instead of:
```ruby
Math.sqrt(Integer(42, exception: false))
```
Since this seems like the opposite direction of `|>`, might `<|` be an acceptable alternative to `>>>`?
```ruby
1.. <| take 10 <| map {|e| e*2} <| (x)
#=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
1.. |> take 10 |> map {|e| e*2} |> (x)
#=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
1.. >>> take 10 >>> map {|e| e*2} >>> (x)
#=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
```
----------------------------------------
Feature #15799: pipeline operator
https://bugs.ruby-lang.org/issues/15799#change-78629
* Author: nobu (Nobuyoshi Nakada)
* Status: Closed
* Priority: Normal
* Assignee:
* Target version:
----------------------------------------
Implemented the pipeline operator `|>`, a topic of "ruby committers vs the world" in RubyKaigi 2019.
Also a casual idea of rightward assignment.
```ruby
1.. |> take 10 |> map {|e| e*2} |> (x)
p x #=> [2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
```
https://github.com/nobu/ruby/tree/feature/pipeline
--
https://bugs.ruby-lang.org/
Unsubscribe: <mailto:ruby-core-request@ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>