Issue #17260 has been updated by Dan0042 (Daniel DeLorme).


matz (Yukihiro Matsumoto) wrote in #note-1:
> I have a secret plan to make right hand assignment a replacement for single line pattern match.

I find myself liking this idea a lot.

In #13683 nobu suggested pattern matching as a replacement for `v = ary.single`, and while `ary in [v]` is conceptually elegant, `ary => [v]` feels a lot more intuitive. In fact, `expr in pattern` can feel so unintuitive that #16670 even suggested to reverse the order; but this would not be an issue if `=>` was used instead of `in`.

If `=>` does not allow the full range of pattern matching due to syntax restrictions, maybe consider a different operator like `~>` or those I proposed in #16794. And perhaps `~>` as rightward assignment could also be used to resolve the ambiguity of `=>` described in #16960.

----------------------------------------
Feature #17260: Promote pattern matching to official feature
https://bugs.ruby-lang.org/issues/17260#change-88002

* Author: ktsj (Kazuki Tsujimoto)
* Status: Open
* Priority: Normal
* Target version: 3.0
----------------------------------------
I propose to promote pattern matching to official feature.

The current specification is basically fine, but I'd like to reconsider single line pattern matching (`expr in pat`) and suggest removing it once in 3.0.




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