May 2018
Beginner to intermediate
290 pages
6h 43m
English
There’s even more good news with destructuring: it also works with maps. The idea behind destructuring a map is the same as with the sequential types. You provide a template for the data structure—a template that includes the symbols that you want to bind to various values in the map. To see how map destructuring works, consider that when you build a map, you supply a bunch of keys and values:
| | (def artist-map {:painter :monet :novelist :austen}) |
Here we’re saying Associate :monet with :painter and :austen with :novelist. That is, this key with that value. In the template that you provide in a map destructuring, you do something very similar. You provide a series of symbols and keys. Like this:
| | (let [{painter :painter ... |
Read now
Unlock full access