toStringtoInt1 88] 프로그래머스 숨어있는 숫자의 덧셈 (1) Kotlin char는 toInt 했을때 int가 반환되지 않는다. char.toString().toInt() 해줘야한다. class Solution { fun solution(my_string: String): Int { var answer: Int = 0 for(i in 0 until my_string.length){ if(my_string[i] in '1' .. '9') { answer += my_string[i].toString().toInt() } } return answer } } https://kotlinworld.com/436 [Kotlin] Char을 Int로 변환하는 세가지 방법 알아보기 : Char to IntChar을 Int로 변환할 때 많은 실수가 생기는 이유 Kotlin은 하나의 자료형을 다.. 2023. 10. 23. 이전 1 다음