Project

General

Profile

Actions

Feature #17411

closed

Allow expressions in pattern matching

Added by zverok (Victor Shepelev) about 1 year ago. Updated 10 months ago.

Status:
Closed
Priority:
Normal
Target version:
-
[ruby-core:101546]

Description

Code:

version = {name: '2.6', released_at: Time.new(2018, 12, 25)}
version in {released_at: Time.new(2010)..Time.new(2020)}
#                            ^ syntax error, unexpected '.', expecting '}'

# This works:
range = Time.new(2010)..Time.new(2020)
version in {released_at: ^range}
#=> true

(Fails with all versions of the pattern matching, in, => and case ... in, and on Ruby 2.7 too.)

Am I missing something about the syntax?..

Actions

Also available in: Atom PDF