How to get the values of a dictionary in Swift

2 Answers

0 votes
var dict:[String:Int] = ["Swift": 3, "Java": 9, "C": 5, "Python": 1] 
 
print(dict.values)
 

 
 
/*
run:
 
[9, 3, 5, 1]
 
*/


  
  

 



answered Jun 16, 2023 by avibootz
0 votes
var dict:[String:Int] = ["Swift": 3, "Java": 9, "C": 5, "Python": 1] 
 
for val in dict.values {
    print(val)
}
 

 
 
/*
run:
 
1
9
3
5
 
*/


  
  

 



answered Jun 16, 2023 by avibootz

Related questions

1 answer 175 views
1 answer 202 views
202 views asked Sep 19, 2020 by avibootz
2 answers 262 views
3 answers 216 views
...