Project

General

Profile

Actions

Feature #17411

closed

Allow expressions in pattern matching

Added by zverok (Victor Shepelev) about 4 years ago. Updated almost 4 years ago.

Status:
Closed
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

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0Like0