The range keyword is used in Go to loop over elements in a(n) _____.

  • array
  • map
  • slice
  • struct
In Go, the range keyword is primarily used to loop over elements in a slice. It allows you to iterate through each element of a slice, providing both the index and the value for each element. While it can be used with other data structures like maps and arrays, it's most commonly used with slices to simplify iteration through collections of data.
Add your answer
Loading...

Leave a comment

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