From: eregontp@...
Date: 2020-05-02T11:45:19+00:00
Subject: [ruby-core:98114] [Ruby master Feature#15921] R-assign	(rightward-assignment) operator

Issue #15921 has been updated by Eregon (Benoit Daloze).


I think it would be good to make it a habit to justify any syntax change with some motivation.
For instance, I would suggest making sure the point is clear in the ticket before accepting a syntax change.

I don't see much examples here, where normal assignment wouldn't work just fine and be as or more readable (`fib(10) => x` in the NEWS seems no better than `x = fib(10)`).
In fact the only examples seem to be from @ioquatix, and the second one only applies to REPL.
For the `if` case I would usually just assign in both branches, which generalizes nicely if there is more than one variable to assign from the `if`.

It seems I'm not alone wonder the usefulness of this change:
https://twitter.com/devoncestes/status/1256222228431228933
https://twitter.com/eregontp/status/1256544073554563072

----------------------------------------
Feature #15921: R-assign (rightward-assignment) operator
https://bugs.ruby-lang.org/issues/15921#change-85356

* Author: nobu (Nobuyoshi Nakada)
* Status: Closed
* Priority: Normal
* Assignee: matz (Yukihiro Matsumoto)
----------------------------------------
From https://bugs.ruby-lang.org/issues/15799#change-78465, proposal of the rightward-assignment operator by `=>`.

```
$ ./ruby -v -e '(1..).lazy.map {|x| x*2} => x' -e 'p x.first(10)'
ruby 2.7.0dev (2019-06-12T06:32:32Z feature/rassgn-assoc c928f06b79) [x86_64-darwin18]
last_commit=Rightward-assign by ASSOC
[2, 4, 6, 8, 10, 12, 14, 16, 18, 20]
```

https://github.com/nobu/ruby/tree/feature/rassgn-assoc



-- 
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>