Advertisement
Guest User

Untitled

a guest
Mar 21st, 2019
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.51 KB | None | 0 0
  1. //Will declare a map of string keys, int values.
  2.  
  3. var timeZone = map[string]int{
  4. "UTC": 0*60*60,
  5. "EST": -5*60*60,
  6. "CST": -6*60*60,
  7. "MST": -7*60*60,
  8. "PST": -8*60*60,
  9. }
  10.  
  11. //You can create a set-like structure using a map by setting the value of each key to bool.
  12.  
  13. attended := map[string]bool{
  14. "Ann": true,
  15. "Bobby": true
  16. }
  17.  
  18. //This is useful now because you can check for existence in the map
  19. if attended[somePerson] { //Will return false if somePerson isn't in the map
  20. fmt.Printf("%v was present.\n")
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement