How to decrease value in dictionary with Swift

1 Answer

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

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

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

*/

 



answered Sep 20, 2020 by avibootz

Related questions

1 answer 175 views
2 answers 233 views
2 answers 184 views
1 answer 162 views
2 answers 187 views
...