What is equivalent to Swift's HashSet Java script?

I have specific logic in Java that uses a HashSet<String> . Collection set contains only unique elements.

For instance:

 Set<String> mySets = new HashSet<String>(); mySets.add("a"); mySets.add("a"); mySets.add("b"); mySets.add("a"); 

I get: ["a","b"] .

What is the equivalent collection in Swift?

Thanks,

+5
source share
1 answer

Swift (and Objective-C), equivalent to Java HashSet , NSSet .

Example:

 var s = NSMutableSet() s.addObject("a") s.addObject("a") s.addObject("b") s.addObject("a") println("s: \(s)") 

exit:

 s: {( a, b )} 
+14
source

Source: https://habr.com/ru/post/1200034/


All Articles