Consider the following snippet from my Xcode Playground:
import UIKit
var collection = Set<String>() {
didSet {
print("didSet")
}
}
collection.insert("Test1")
collection.insert("Test2")
collection.insert("Test1")
collection.insert("Test3")
print("Done")
Why is the output:
didSet
didSet
didSet
didSet
Done
instead of:
didSet
didSet
didSet
Done
Why does it fire when the set isn't changed, since the value is already in the set?