diff --git a/modern-android-compose/section00/app/src/main/java/com/ocomwan/kotlinbasics/Main.kt b/modern-android-compose/section00/app/src/main/java/com/ocomwan/kotlinbasics/Main.kt index 5ad3d39..8000a81 100644 --- a/modern-android-compose/section00/app/src/main/java/com/ocomwan/kotlinbasics/Main.kt +++ b/modern-android-compose/section00/app/src/main/java/com/ocomwan/kotlinbasics/Main.kt @@ -8,7 +8,7 @@ import kotlin.random.Random const val num = 20 // Compile Time Constant fun main() { - practiceArray() + practiceNullSafety() } private fun practicePrint() { @@ -150,3 +150,20 @@ private fun practiceArray() { print(e.message) } } + +private fun practiceNullSafety() { + var name: String? = null + name = "채연" + name = null + + var name2: String = "" + if (name != null) { + name2 = name + } + + name2 = name!! + + name?.let { + name2 = name + } +}