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
The documentation currently just states "we're calling the unapply method", without giving any indication to *how* it's being called. Saying something like "we're calling the unapply method with `CustomerID.unapply(customer1ID)`" or "we're calling the unapply method with `name=CustomerID.unapply(customer1ID)`", while maybe not strictly accurate, helps give readers a better understanding of what's going on. I know for me personally I found this very confusing, and a line or two about this would have been very helpful.
Copy file name to clipboardExpand all lines: _tour/extractor-objects.md
+1-1Lines changed: 1 addition & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -32,7 +32,7 @@ customer1ID match {
32
32
}
33
33
```
34
34
35
-
The `apply` method creates a `CustomerID` string from a `name`. The `unapply` does the inverse to get the `name` back. When we call `CustomerID("Sukyoung")`, this is shorthand syntax for calling `CustomerID.apply("Sukyoung")`. When we call `case CustomerID(name) => println(name)`, we're calling the unapply method.
35
+
The `apply` method creates a `CustomerID` string from a `name`. The `unapply` does the inverse to get the `name` back. When we call `CustomerID("Sukyoung")`, this is shorthand syntax for calling `CustomerID.apply("Sukyoung")`. When we call `case CustomerID(name) => println(name)`, we're calling the unapply method with `CustomerID.unapply(customer1ID)`.
36
36
37
37
Since a value definition can use a pattern to introduce a new variable, an extractor can be used to initialize the variable, where the unapply method supplies the value.
0 commit comments