Skip to content

Does the new pattern proposal allow user defined equality? #2378

@leafpetersen

Description

@leafpetersen

[Updated: This was an overly terse summary, which caused some confusion. I've elaborated (hopefully more clearly) here]

The current rules for switches require that constants in switches come from classes that do not override equality. The new pattern proposal adds a relational pattern == constant which is defined to call the equality operator on the receiver (and also relational operators similarly).

  • Is == constant intended to work when the receiver overrides operator ==?
  • Does the proposal eliminate the current error for existing switches?

cc @lrhn @eernstg @munificent @stereotype441 @natebosch @jakemac53

Metadata

Metadata

Assignees

Labels

patternsIssues related to pattern matching.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions