SHARE
TWEET

my arrays

a guest Sep 22nd, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //associative array
  2. var userGrades:[String:Int] = [:]
  3. userGrades["Neo"]=0
  4. userGrades["Shlomi"]=100 //becuase i affraid from shlomi
  5. userGrades["Gal"]=100
  6. userGrades["Faiz"]=100
  7. userGrades["Michel"]=60 //becuase i am a racist
  8.  
  9. print (userGrades)
  10. userGrades["Michel"]=65
  11. print (userGrades)
  12.  
  13. print (userGrades["Shlomi"]!)
  14.  
  15.  
  16. var userId:[Int:String] = [:]
  17. userId[723784]="Neo"
  18. userId[387234]="Faiz"
  19.  
  20. print (userId)
  21. print ("\(userId[723784]!) wants badly \(userId[387234]!)")
  22.  
  23. //set - stores only unique values
  24. var mySet = Set<String>()
  25. mySet.insert("zeev")
  26. mySet.insert("nipo")
  27. mySet.insert("amital")
  28. mySet.insert("nipo")
  29.  
  30. print (mySet)
  31. print (mySet.count)
  32. var check=mySet.contains("nipo")
  33. print ("we have the dog here? \(check)")
  34.  
  35.  
  36. //if commands
  37. if mySet.contains("neo") && mySet.contains("zeev")
  38. {
  39.     print ("nipo is still alive, how sad")
  40. }
  41. else
  42. {
  43.     print ("finnaly, freedom !!!!")
  44. }
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
 
Top