Created
April 26, 2020 11:26
-
-
Save gyugyu90/47f55da007953330493b1e99eb460f57 to your computer and use it in GitHub Desktop.
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
fun parseInt(str: String): Int? { | |
return str.toIntOrNull() | |
} | |
fun printProduct(arg1: String, arg2: String) { | |
val x = parseInt(arg1) | |
val y = parseInt(arg2) | |
if (x == null) { | |
println("arg1은 숫자 포맷이 아닙니다: '$arg1'") | |
} | |
if (y == null) { | |
println("arg2은 숫자 포맷이 아닙니다: '$arg2'") | |
} | |
println(x + y) | |
} | |
fun main() { | |
printProduct("6", "7") | |
printProduct("a", "7") | |
printProduct("99", "b") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment