Curriculum Collections & iteration Hash maps exercise 4 · fill-word
Hash maps
Fill the type name in the import that brings the standard hash-map into scope.
TypeScript reference
Fill the blanks →
About this theme
HashMap<K, V> replaces many TypeScript object-as-map patterns, but lookups return Option<&V> and insertion may move keys and values. Planned exercises: 1. choose HashMap. 2. recognise insert. 3. choose .get() return type. 4. fill an import from std::collections. 5. fill entry(...).or_insert(...). 6. write a frequency counter. 7. write a lookup with a fallback. 8. translate TS record code. 9. fix a borrowed-key lookup without cloning unnecessarily.