Skip to content

Named fields in pattern match - #3319

Open
som-snytt wants to merge 2 commits into
scala:mainfrom
som-snytt:issue/3313-match-named
Open

Named fields in pattern match#3319
som-snytt wants to merge 2 commits into
scala:mainfrom
som-snytt:issue/3313-match-named

Conversation

@som-snytt

Copy link
Copy Markdown
Contributor

Fixes #3313

@som-snytt
som-snytt requested a review from SethTisue September 1, 2026 00:18
Comment thread _tour/pattern-matching.md
and ignores `body` with the special pattern that is just an underscore, `_`.

The fields of interest can also be named in Scala 3, like named arguments, of the form `name = pattern`:
```scala

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if i was puttin on my consistency hat then this should use the tabs design:

{% tabs named_pattern_match %}
{% tab 'Scala 3 Only' for=named_pattern_match %}
```scala
case Email(sender = sender, title = subject) =>
```
{% endtab %}
{% endtabs %}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Binding a pattern match variable by field name is not mentioned

2 participants