February 2018
Beginner
200 pages
4h 37m
English
Pattern matching is also useful for extracting parts of values to variables in a process called destructuring. It’s our primary tool to get a string part, an item from a list, and a value from the map. We use destructuring together with pattern matching when we’re making two things match. In this section, we’ll explore pattern matching with several data types and see how we can extract values and make more complex matches.
Strings are a data type that we can use in pattern matching. We can use the <> operator to check the beginning of a string. It’s useful for checking text that’s organized in key/value pairs. For example, we can match one header pattern in the HTTP protocol. ...
Read now
Unlock full access