Created
April 30, 2016 18:39
-
-
Save goodmorningcody/e01b838c746ee356eac138b331498eaa to your computer and use it in GitHub Desktop.
스위프트 : if let 구문을 활용한 옵셔널 타입의 효과적인 조건 분기
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
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