-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pattern matching documentation #2565
Conversation
def apply(i: Int, s: String): CC = new CC(i, s) | ||
def unapply(cc: CC): CC = cc | ||
} | ||
``` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A reference to this page needs to be added to sidebar.yml
and index.md
to be visible to all :)
a8e18ef
to
bdde62c
Compare
Does this describe the current state of Dotty after 3e04b6f ? |
|
||
Boolean Pattern | ||
|
||
- Extractor defines `def unapply(x: T): Boolean` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it would be nice to give examples instead of rules. More accessible.
|
||
In case of ambiguities, *Product Pattern* is preferred over *Name Based Pattern*. | ||
|
||
Dotty pattern matching is not special cased to case classes. Instead, allocation of Tuples and Options is avoided by desugaring case classes to use a *Product Pattern* extractor: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not clear what does this mean without context. I think we should either introduce scalac story here, or simply drop this sentence.
I'd propose to include that Dotty-generated patterns are a LOT easier to debug, as variables will show-up in debug modes. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Small suggestions, Otherwise LGTM
bdde62c
to
f6438dc
Compare
- Add a bunch of links to dotty.epfl.ch - Clean up / update the features list
f6438dc
to
70d896c
Compare
@DarkDimius I've incorporated your suggestions, I think the pattern matching doc needs another review. |
@odersky @DarkDimius This is very minimal, anything else you would like to see included?