Skip to content

Instantly share code, notes, and snippets.

@CenoX
Created March 28, 2018 08:14
Show Gist options
  • Save CenoX/8979d19b6ed2dd99b93afb3f81a37cd4 to your computer and use it in GitHub Desktop.
Save CenoX/8979d19b6ed2dd99b93afb3f81a37cd4 to your computer and use it in GitHub Desktop.
King-God-Emperor-ChungMuGong-Majesti-General-Development Master God GyungDal
enum Rank {
case top
case mid
case low
func whoIsHim() -> String {
if self == .top { return "GyungDal" }
return "I don't know"
}
}
enum RankError: Error {
case HeIsDenying
}
struct GyungDal {
public private(set) var rank = Rank.top
var isHeThinksHeIsNotTopRanker = true
func checkHim() throws {
if isHeThinksHeIsNotTopRanker {
throw RankError.HeIsDenying
} else {
print("Yeah. GyungDal is Top Ranker")
}
}
init() {}
}
var gyungDal = GyungDal()
do {
try gyungDal.checkHim()
} catch RankError.HeIsDenying {
print("Fuck. He is denying that he is top ranker!!")
print("We should change his mind.")
gyungDal.isHeThinksHeIsNotTopRanker = false
dump(gyungDal)
print("Jung2GooHyun Done.")
try gyungDal.checkHim()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment