var wine = Set<String>()
wine.insert("Champagne")
wine.insert("Champagne")
enum Booze: String {
case wine,
case champagne,
case beer,
case whiskey
}
let wine = [Booze.champagne]
</ocd> enum Booze {
case Wine(region: String)
case Beer
case Whiskey
}
let drink = Booze.Wine(region: "Champagne")
Now.. Anyone want to demonstrate how to use enums for the wine region or, say, whiskey subtypes? Should we use classes?But yes, in Swift, arrays, dictionaries, sets and strings are all mutable. They are also value types, so mutation is a purely local effect.
let array = [1, 2, 3] var mutableArray = [4, 5, 6] var anotherMutable = array
Not sure how much optimisation is done under the hood, but Swift compiler loves to complain about mutable structures that are not ever edited.