Summary from HackingWithSwift.com
The CaseIterable protocol provides an allCases method that turns all of your cases into an array.
enum Pasta: String, CaseIterable {
case canneloni = "Cannelloni pasta"
case fusilli = "Fusilli pasta"
case linguini = "Linguini pasta"
case taliatelle = "Taliatelle pasta"
}
Pasta.allCases.forEach{ pastaType in
print("\(pastaType.rawValue)")
}
Random number generator for range. Cleaner syntax than arc4random_uniform()
let randomNumber = Int.random(in: 1...1000)
.allSatisfy returns a Bool for conditions specified on an array
let scores = [85, 84, 95, 92]
let passed = scores.allSatisfy{ $0 >= 85 } // returns Bool
.removeAll now allows you to specify a filter to remove items from an array
var theBigLebowski = ["The Dude", "Angry Walter", "Maude Lebowski", "Donny Kerabatsos", "The Big Lebowski", "Little Larry Sellers"]
theBigLebowski.removeAll{ $0.contains("Lebowski")}
.toggle() allows you to toggle a boolean without having to assign it
var myBool = true
myBool.toggle() // flips to false