From: eregontp@... Date: 2019-06-30T09:52:15+00:00 Subject: [ruby-core:93424] [Ruby trunk Feature#15799] pipeline operator Issue #15799 has been updated by Eregon (Benoit Daloze). inopinatus (Joshua GOODALL) wrote: > ``` ruby > result = 3 |> pow(2) #=> 9 > result #=> 3 (!?!?!) > ``` This makes it clear to me: the pipeline operator just seems a hack to avoid parentheses around Range literals. The precedence seems not intuitive. Unlike `and`, where `if a = 3*2 and a == 6` is rather clear, here assignment before |> is never wanted. So probably assignment before |> should be a SyntaxError. This syntax saves Range literal parenthesis, but it doesn't even save characters, so I see not point for it as it is. Others will say it's nice for multi-line method call chains, but `.` works just fine in that case too when using indentation: ```ruby 1.. |> take 10 |> each { |x| p x } (1..) .take(10) .each { |x| p x } ``` (the example is from @mame's post) Finally, as other have said, the most essential operator of OO languages, the method call operator, does not need to be reinvented, `.` works just fine. ---------------------------------------- Feature #15799: pipeline operator https://bugs.ruby-lang.org/issues/15799#change-78966 * 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: