How to increase value in dictionary with Swift

1 Answer

0 votes
var dic : [String: Int] = ["Swift": 4, "Python": 7, "Java": 6, "PHP": 5]
  
dic["Swift"]? += 10

for (key, value) in dic {
    print(key, value)
}

  
  
/*
run:
  
PHP 5
Java 6
Python 7
Swift 14

*/

 



answered Sep 20, 2020 by avibootz

Related questions

1 answer 173 views
2 answers 231 views
2 answers 180 views
1 answer 161 views
2 answers 183 views
...