Skip to content

Instantly share code, notes, and snippets.

@gyugyu90
Created April 26, 2020 11:26
Show Gist options
  • Save gyugyu90/47f55da007953330493b1e99eb460f57 to your computer and use it in GitHub Desktop.
Save gyugyu90/47f55da007953330493b1e99eb460f57 to your computer and use it in GitHub Desktop.
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