Issue #15799 has been updated by konsolebox (K B).


konsolebox (K B) wrote:
> nobu (Nobuyoshi Nakada) wrote:
> > duerst (Martin D=FCrst) wrote:
> > > As for the assignment, just using parentheses looks confusing to me. =
It's clear we can't use `>=3D` or `|=3D`, but `|>=3D` or some other combina=
tion would be much clearer than just parentheses.
> > =

> > OK, I separated the right-assign to https://github.com/nobu/ruby/tree/f=
eature/rassgn-pipeline,
> > and another operator https://github.com/nobu/ruby/tree/feature/rassgn-f=
unnel.
> =

> `|>=3D` looks heavy.  Please consider `|:` instead.

Or `=3D:` which is the reverse of Pascal's assignment operator.  Personally=
 I would want it to have it as an alias to `|:` than replace `|:` because `=
=3D:` would look good if it's placed last, but `|:` would look better halfw=
ay.

``` ruby
1.. |> take 10 |: ten |> map{ |x| x * 2 } =3D: doubled
```

My opinion on this new set of operators is that they're good for writing dr=
afts of code quickly because you can easily place an assignment to a variab=
le at the end of a statement, or insert it somewhere, but old-school is bet=
ter 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 #=3D> [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=3Dunsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>