When accessing a map value in Go, a second optional _____ value can be used to check if the key exists.

  • error
  • bool
  • panic
  • string
In Go, when accessing a map, you can use a second optional value to check if the key exists. This value is of type bool. It is a useful practice to use this boolean value to avoid runtime panics when trying to access a key that doesn't exist in the map. The correct option is (2) bool.
Add your answer
Loading...

Leave a comment

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