Title here
Summary here
Our example demonstrates how to iterate over elements in various built-in data structures. Let’s see how to use range
with some of the data structures we’ve already learned.
Here we use for in
to sum the numbers in an array.
for in
on arrays provides both the index and value for each entry. Above we didn’t need the index, so we ignored it with the _
placeholder. Sometimes we actually want the indexes though.
for in
on Map
iterates over key/value pairs.
for in
can also iterate over just the keys of a Map
.
for in
on strings iterates over Unicode code points. The first value is the starting byte index of the Char
and the second the Char
itself.