How to create an empty set in Swift

1 Answer

0 votes
let intSet = Set<Int>()
let stringSet = Set<String>()
let boolSet = Set<Bool>()
let floatSet = Set<Float>()

print(intSet)
print(stringSet)
print(boolSet)
print(floatSet)

print(intSet.isEmpty)
print(stringSet.isEmpty)
print(boolSet.isEmpty)
print(floatSet.isEmpty)





/*
run:

[]
[]
[]
[]
true
true
true
true

*/

 



answered Jun 13, 2023 by avibootz

Related questions

1 answer 194 views
1 answer 174 views
174 views asked Sep 19, 2020 by avibootz
1 answer 241 views
241 views asked Sep 1, 2020 by avibootz
1 answer 103 views
1 answer 99 views
...