The _______ statement in Go is used to iterate over elements in an array, slice, string, or map.

  • for
  • if
  • switch
  • range
The correct option is "range". In Go, the "range" statement is used to iterate over elements in various data structures such as arrays, slices, strings, or maps. It simplifies the process of looping through the elements of these data structures by providing a concise syntax. The "range" statement is versatile and allows iterating over different types of collections, making it a powerful tool for traversal and processing of data in Go programs.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *