You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: _tour/pattern-matching.md
+63Lines changed: 63 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -138,6 +138,69 @@ println(showNotification(someVoiceRecording)) // prints You received a Voice Re
138
138
139
139
The function `showNotification` takes as a parameter the abstract type `Notification` and matches on the type of `Notification` (i.e. it figures out whether it's an `Email`, `SMS`, or `VoiceRecording`). In the `case Email(sender, title, _)` the fields `sender` and `title` are used in the return value but the `body` field is ignored with `_`.
140
140
141
+
## Matching on string
142
+
143
+
The `s`-interpolator allows embedding variables in strings and is also useful for pattern matching.
0 commit comments