[ruby-core:101857] [Ruby master Feature#15921] R-assign (rightward-assignment) operator
From:
marcandre-ruby-core@...
Date:
2021-01-01 15:13:56 UTC
List:
ruby-core #101857
Issue #15921 has been updated by marcandre (Marc-Andre Lafortune).
dgutov (Dmitry Gutov) wrote in #note-25:
> It's not like the new syntax makes anything possible that a simple assignment does not.
It does. It is now a pattern match, not just a rightward assignment:
```ruby
{x: 1, y: 2} => {x:}
# now x holds 1
```
Please refer to the doc on pattern matching. https://docs.ruby-lang.org/en/master/doc/syntax/pattern_matching_rdoc.html
----------------------------------------
Feature #15921: R-assign (rightward-assignment) operator
https://bugs.ruby-lang.org/issues/15921#change-89694
* 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>