SHARE
TWEET

Untitled

a guest Mar 21st, 2019 68 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top