728x90
Kotlin
-
kotlin null safety카테고리 없음 2022. 10. 4. 13:45
코틀린을 시작하면서 신기한 연산자를 정리 했습니다. 기본적으로 kotlin은 null을 허용하지 않습니다. 다만 명시적으로 null을 허용할수 있는데요. // null 할당시 오류 var a: String = "abc" // Regular initialization means non-null by default a = null // compilation error // null 명시적 허용 처리 var b: String? = "abc" // can be set to null b = null // ok print(b) // null 인 b의 length에 접근시 오류 발생 val l = b.length // error: variable 'b' can be null 명시적으로 null을 허용하게 하였다면, ..