A new Set data structure
About 2 min
A new Set data structure 관련
HACKING WITH SWIFT
What's new in Swift?
A new Set data structure | Changes in Swift 1.2
A new Set data structure
Available from Swift 1.2
Swift 1.2 introduced a new Set
type that works similarly to NSSet
except with value semantics. Sets work similarly to arrays except they are not ordered and do not store any element more than once. For example:
var starships = Set<String>()
starships.insert("Serenity")
starships.insert("Enterprise")
starships.insert("Executor")
starships.insert("Serenity")
starships.insert("Serenity")
Even though that code tries to insert Serenity three times, it will only be stored in the set once.
Other changes in Swift 1.2…
The zip() function joins two sequences | Changes in Swift 1.2
The zip() function joins two sequences
The flatMap() method transforms optionals and arrays | Changes in Swift 1.2
The flatMap() method transforms optionals and arrays
Closures can now be marked @noescape | Changes in Swift 1.2
Closures can now be marked @noescape
Classes can now have static methods and properties | Changes in Swift 1.2
Classes can now have static methods and properties
Constants no longer require immediate initialization | Changes in Swift 1.2
Constants no longer require immediate initialization
Implicit bridging has been reduced | Changes in Swift 1.2
Implicit bridging has been reduced
Multiple if let bindings | Changes in Swift 1.2
Multiple if let bindings
Typecasting now includes as! | Changes in Swift 1.2
Typecasting now includes as!