Project

General

Profile

Actions

Feature #20070

open

commas in pattern match

Added by Dan0042 (Daniel DeLorme) 5 months ago. Updated 5 months ago.

Status:
Open
Assignee:
-
Target version:
-
[ruby-core:115772]

Description

In pattern matching, case v; in 1,2,3 is a synonym for case v; in [1,2,3]

This is the one thing that keeps confusing me, that I haven't been able to get used to. Because I'm used to case v; when 1,2,3 it feels like case v; in 1,2,3 should have a similar meaning. So it's possible to omit the square brackets but honestly I don't see much point for that, it just makes it look to me like something it is not.

In other words, I feel it would be far more intuitive (at least to me) if

case v
in 1,2,3

was a synonym for

case v
in 1
in 2
in 3

or possibly a synonym for

case v
in (1|2|3)

which would make it similar to the syntax in rescue A, B, C => err

Is it too late to change this?

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0