Hacker News new | ask | show | jobs
by orf 1273 days ago
I don’t understand the issue - why was it reverted? Are there multiple ways to do pattern matching? Why?
2 comments

I read that comment, but unless you know Ruby most of the specifics are meaningless
think of pattern matching being implemented via methods on an object which return a hash/array (deconstruct and deconstruct_keys).

ActiveRecord objects wrap an hash of attributes, but are also normal objects which have instance variables and methods plus some hooks and specific API that can be expected to be overriden.

So it's unclear how the method should behave: just read from the hash? Invoke some specific method? Invoke any method?

The answer may be non obvious.

I think it was reverted because the Rails team isn't sure what values of a model should be available to pattern match, and how each attribute or association should be pattern matched.