This file contains hidden or 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 Stage: String { | |
case production | |
case staging | |
case dev | |
case local | |
init?(rawValue: String) { | |
switch rawValue.lowercased() { | |
case "prod", "production": self = .production | |
case "qa", "staging": self = .staging | |
case "dev": self = .dev |
This file contains hidden or 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 Stage: String { | |
case production = "prod" | |
case staging | |
case dev | |
case local | |
} | |
let stage = Stage.production | |
let params = ["stage" : stage.rawValue] // ["stage": "prod"] |
This file contains hidden or 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
let stage = Stage.production | |
let params = ["stage" : stage.rawValue] // ["stage": "production"] |
This file contains hidden or 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 Stage: String { | |
case production | |
case staging | |
case dev | |
case local | |
} |
This file contains hidden or 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 Game { | |
case singlePlayer(SinglePlayerGame) | |
case multiPlayer(MultiPlayerGame) | |
case ai(AIGame) | |
} | |
let aiGame = ... | |
let game = Game.ai(aiGame) |
This file contains hidden or 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
struct SinglePlayerGame { | |
let id: String | |
let numOfPlayers: Int | |
let weaponsCollected: [String] | |
} |
This file contains hidden or 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 DateType { | |
case concrete(Date) | |
case range(Range<Date>) | |
} |
This file contains hidden or 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
let data: [Any] = [Date(), "string", 123] | |
for elem: Any in data { | |
switch elem { | |
case let stringVal as String: // handle string | |
case let intVal as Int: // handle integer | |
case let dateVal as Date: // handle date | |
default: // handle others | |
} | |
} |
This file contains hidden or 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
func logEvent(event: AnalyticsEvent) { | |
switch event { | |
case .sendFeedback(_: String, content: String): | |
print("\(content)") | |
// rest of the cases | |
} | |
if case let AnalyticsEvent.sendFeedback(_, content) = event { | |
print("\(content)") | |
} |
This file contains hidden or 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
let feedbackEvent = AnalyticsEvent.sendFeedback(userId: "id", content: "content") |
NewerOlder