From: konsolebox@... Date: 2019-05-28T07:37:45+00:00 Subject: [ruby-core:92872] [Ruby trunk Feature#15799] pipeline operator Issue #15799 has been updated by konsolebox (K B). konsolebox (K B) wrote: > nobu (Nobuyoshi Nakada) wrote: > > duerst (Martin D�rst) wrote: > > > As for the assignment, just using parentheses looks confusing to me. It's clear we can't use `>=` or `|=`, but `|>=` or some other combination would be much clearer than just parentheses. > > > > OK, I separated the right-assign to https://github.com/nobu/ruby/tree/feature/rassgn-pipeline, > > and another operator https://github.com/nobu/ruby/tree/feature/rassgn-funnel. > > `|>=` looks heavy. Please consider `|:` instead. Or `=:` which is the reverse of Pascal's assignment operator. Personally I would want it to have it as an alias to `|:` than replace `|:` because `=:` would look good if it's placed last, but `|:` would look better halfway. ``` ruby 1.. |> take 10 |: ten |> map{ |x| x * 2 } =: doubled ``` My opinion on this new set of operators is that they're good for writing drafts of code quickly because you can easily place an assignment to a variable at the end of a statement, or insert it somewhere, but old-school is better for formal writes since it's more readable. In old-school assignments, you can easily find where the assignment happens and know when it happens. ---------------------------------------- Feature #15799: pipeline operator https://bugs.ruby-lang.org/issues/15799#change-78251 * Author: nobu (Nobuyoshi Nakada) * Status: Open * 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 {|x| x*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: