연습장/프로그래머스

프로그래머스(Kotlin)_ 문자열을 정수로 바꾸기

아이른 2024. 2. 14. 18:31

 

1. s를 정수로 바꾸기. toInt()

class Solution {
    fun solution(s: String): Int {
       var answer = 0
       answer = s.toInt()
       return answer
    }
}

class Solution {
    fun solution(s: String): Int {
        return s.toInt()
    }
}

class Solution {
    fun solution(s: String): Int = s.toInt()
}