Created
October 7, 2018 16:50
-
-
Save yunustek/1a754f33e3d07ac2b6065fd74bef8977 to your computer and use it in GitHub Desktop.
Derived Collection of Enum Cases:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum CompassDirection: CaseIterable { | |
case north, south, east, west | |
} | |
print("There are \(CompassDirection.allCases.count) directions.") | |
// Prints "There are 4 directions." | |
let caseList = CompassDirection.allCases | |
.map({ "\($0)" }) | |
.joined(separator: ", ") | |
// caseList == "north, south, east, west" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment