September 2015
Intermediate to advanced
250 pages
6h 40m
English
You already saw how to define placeholder vals for what you’re matching, like lat and long when matching tuples. These are pattern variables. However, you have to be careful when defining them. By convention, Scala expects the pattern variables to start with a lowercase letter and constants to be capitalized.
If you use a capitalized name, it will look for a constant in the scope; however, if you use a noncapitalized name, it will merely assume it’s a pattern variable—any variable or constant with the same noncapitalized name in the scope will be ignored. In the next code, we’re defining a pattern variable with the same name as a field, but the code will not give us the desired result—the pattern ...
Read now
Unlock full access