Introduction
The range
keyword is used to iterate over elements in a variety of data structures in Golang. In this challenge, we will explore how to use range
with different data structures.
This tutorial is from open-source community. Access the source code
The range
keyword is used to iterate over elements in a variety of data structures in Golang. In this challenge, we will explore how to use range
with different data structures.
The problem to be solved in this challenge is to demonstrate how to use range
with slices, arrays, maps, and strings.
To complete this challenge, you will need:
$ go run range.go
sum: 9
index: 1
a - > apple
b - > banana
key: a
key: b
0 103
1 111
In this challenge, we learned how to use range
with slices, arrays, maps, and strings in Golang. The range
keyword provides a convenient way to iterate over elements in different data structures.