Iterating over Maps

Let’s learn how to iterate over maps.

We'll cover the following

When for is combined with the range keyword, it implements the functionality of foreach loops found in other programming languages and allows us to iterate over all the elements of a map without knowing its size or its keys. When range is applied on a map, it returns key and value pairs in that order.

Coding example

The following is the forMaps.go program’s code:

Get hands-on with 1200+ tech skills courses.