Issue #15881 has been updated by ko1 (Koichi Sasada).

Assignee set to ktsj (Kazuki Tsujimoto)

----------------------------------------
Feature #15881: Optimize deconstruct in pattern matching
https://bugs.ruby-lang.org/issues/15881#change-80181

* Author: marcandre (Marc-Andre Lafortune)
* Status: Open
* Priority: Normal
* Assignee: ktsj (Kazuki Tsujimoto)
* Target version: 2.7
----------------------------------------
```ruby
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?



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