Upload
kyungho-jung
View
437
Download
1
Embed Size (px)
Citation preview
Null 처리 - Elvis operator
Elvis OperatorWhen we have a nullable reference r, we can say “if r is not null, use it, otherwise use some non-null value x”: -> null 레퍼런스 r을 갖고 있을 때, r이 null이면 사용하고 아니면 non-null value x를 사용하라
val l: Int = if (b != null) b.length else -1Along with the complete if-expression, this can be expressed with the Elvis operator, written ?::
val l = b?.length ?: -1
Kotlin try on online
http://try.kotlinlang.org/#/Kotlin%20Koans/Introduction/Extension%20functions/Task.kt
Using Project Kotlin for Android - JakeWharton
https://docs.google.com/document/d/1ReS3ep-hjxWA8kZi0YqDbEhCqTt29hG8P44aA9W0DM8/edit?hl=ko&forcehl=1#