Project

General

Profile

Actions

Feature #15881

open

Optimize deconstruct in pattern matching

Added by marcandre (Marc-Andre Lafortune) over 5 years ago. Updated 8 months ago.

Status:
Assigned
Target version:
-
[ruby-core:92864]

Description

class A
  def deconstruct
    puts 'deconstruct called'
    [1]
  end
end

case A.new
in [2]
  2
in [1]
  1
else
end

Currently this outputs:

deconstruct called
deconstruct called
=> 1

Shouldn't deconstruct called print only once, whenever the first deconstruction needed occurs?


Related issues 1 (0 open1 closed)

Related to Ruby master - Feature #14912: Introduce pattern matching syntaxClosedktsj (Kazuki Tsujimoto)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0