Skip to content

Commit

Permalink
[ADD/#1] 코틀린 Null Safety 실습
Browse files Browse the repository at this point in the history
  • Loading branch information
b1urrrr committed Dec 5, 2023
1 parent d74f94f commit 63ce96f
Showing 1 changed file with 18 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import kotlin.random.Random
const val num = 20 // Compile Time Constant

fun main() {
practiceArray()
practiceNullSafety()
}

private fun practicePrint() {
Expand Down Expand Up @@ -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
}
}

0 comments on commit 63ce96f

Please sign in to comment.