Skip to content

Instantly share code, notes, and snippets.

@goodmorningcody
Created April 30, 2016 18:39
Show Gist options
  • Save goodmorningcody/e01b838c746ee356eac138b331498eaa to your computer and use it in GitHub Desktop.
Save goodmorningcody/e01b838c746ee356eac138b331498eaa to your computer and use it in GitHub Desktop.
스위프트 : if let 구문을 활용한 옵셔널 타입의 효과적인 조건 분기
let birthString = "1983년"
let currentString = "2015년"
if let birth = Int(birthString), let current = Int(currentString) {
let age = current - birth + 1
}
else {
print("나이 계산을 위해서는 정수값만 입력해야 합니다.")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment