The _______ keyword in Go is used to check if a key exists in a map.

  • _, exists := myMap[key]
  • _, exists = myMap[key]
  • exists := myMap[key]
  • exists = myMap[key]
The _ is a blank identifier used to discard values in Go. When used in conjunction with map lookup, it discards the value but captures whether the key exists or not in the map.
Add your answer
Loading...

Leave a comment

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