{"id":10356,"date":"2020-10-03T13:11:32","date_gmt":"2020-10-03T04:11:32","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=10356"},"modified":"2020-10-05T07:10:34","modified_gmt":"2020-10-04T22:10:34","slug":"kotlin-null-%ea%b2%80%ec%82%ac","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=10356","title":{"rendered":"Kotlin, Null \uac80\uc0ac"},"content":{"rendered":"<p>\uc774\ubbf8 20\ub144 \ub0b4\uc678\ub85c \uac1c\ubc1c\uc790\ub4e4\uc5d0\uac8c \ud3ec\uc778\ud130\ub098 \ucc38\uc870\uc5d0 \ub300\ud55c null\uc740 \uc545\ubabd\uc774\ub77c\uace0 \ud588\ub2e4. \uc0ac\ub78c\uc740 \uc815\ud655\ud558\uac8c \uc791\ub3d9\ud558\ub294 \uae30\uacc4\uac00 \uc544\ub2c8\ubbc0\ub85c, \uadf8\ub0a0\uc758 \ucee8\ub514\uc158\uc774\ub098 \uc2a4\ud2b8\ub808\uc2a4 \ub530\uc704\ub85c \uc2e4\uc218\ub294 \uc5b8\uc81c\ub4e0 \ud560 \uc218 \uc788\ub2e4\ub294 \uc810\uc5d0\uc11c null\uc5d0 \ub300\ud55c \ucc38\uc870\ub294 \ubd84\uba85 \uc545\ubabd\uc758 \uc791\uc740 \ubd88\uc528\uc784\uc5d0\ub294 \ud2c0\ub9bc\uc774 \uc5c6\ub2e4.<\/p>\n<p>Kotlin\uc740 \ucc38\uc870\uc5d0 \ub300\ud55c null \uac12\uc744 \ucd5c\ub300\ud55c \ubc29\uc9c0\ud558\uace0\uc790 \uac12\uc5d0 \ub300\ud574 null \uac12\uc744 \uac00\uc9c8 \uc218 \uc788\ub294 \uacbd\uc6b0\uc640 null \uac12\uc744 \uac00\uc9c0\uc9c0 \ubabb\ud558\ub294 \uacbd\uc6b0\ub85c \ubd84\uba85\ud558\uac8c \ubd84\ub9ac\ub97c \ud588\uc73c\uba70, \uac01\uac01\uc5d0 \ub300\ud574 Nullable\uacfc Non-Null\uc774\ub77c\ub294 \ud0c0\uc785\uc774\uba70 \uae30\ubcf8\uc801\uc774 Kotlin\uc5d0\uc11c\uc758 \uac12\ub4e4\uc740 Non-Null \ud0c0\uc785\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"kotlin\">\r\nvar a:Int = null\r\n<\/pre>\n<p>\uc704\uc758 \ucf54\ub4dc\ub294 Null can not be a value of a non-null type Int\ub77c\ub294 \uc5d0\ub7ec\uac00 \ubc1c\uc0dd\ud55c\ub2e4. \uc774\ub97c \ubc29\uc9c0\ud558\ub824\uba74 \ub2e4\uc74c\ucc98\ub7fc \ucd94\uac00\uc801\uc778 \uc791\uc740 \ucf54\ub4dc\uac00 \ud544\uc694\ud558\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"kotlin\">\r\nvar a:Int? = null\r\n<\/pre>\n<p>Null \uac80\uc0ac\uc5d0 \ub300\ud55c Kotlin\uc758 \ubb38\ubc95\uc5d0\ub294 ?., ?:, !!, ?.let{} \ub4f1\uc774 \uc788\ub2e4. \ud558\ub098\uc529 \uac04\ub7b5\ud558\uac8c \uc815\ub9ac\ud55c\ub2e4.<\/p>\n<h4>?. \uc5f0\uc0b0\uc790<\/h4>\n<p>?.\ub294 \uac12\uc774 null\uc774\uba74 null\uc744 \ubc18\ud658\ud558\uace0 \uad6c\ubb38\uc744 \uc885\ub8cc\ud558\uace0 null\uc774 \uc544\ub2c8\uba74 \uacc4\uc18d \uad6c\ubb38\uc744 \uc2e4\ud589\ud55c\ub2e4\ub294 \uac83\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"kotlin\">\r\nvar a:Int? = 10\r\nprintln(a?.toString())\r\n\r\na = null\r\nprintln(a?.toString())\r\n<\/pre>\n<p>\uc2e4\ud589 \uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class='code'>\r\n10\r\nnull\r\n<\/pre>\n<h4>>?: \uc5f0\uc0b0\uc790<\/h4>\n<p>\uc5d8\ube44\uc2a4 \ud504\ub808\uc2ac\ub9ac\uc758 \ud5e4\uc5b4 \uc2a4\ud0c0\uc77c\uc744 \ub2ee\uc558\ub2e4\uace0\ud574\uc11c \uc5d8\ube44\uc2a4 \uc5f0\uc0b0\uc790\ub79c\ub2e4. \uc7a5\ub09c\ud558\ub0d0? \uc5ec\ud2bc, \uc774 \uc5f0\uc0b0\uc790\ub294 \uac12\uc774 null\uc77c \uacbd\uc6b0\uc5d0 \ub300\ud55c \ub300\uccb4\uac12\uc744 \uc9c0\uc815\ud558\uae30 \uc704\ud55c \uc5f0\uc0b0\uc790\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"kotlin\">\r\nvar a:Int? = 10\r\nprintln(a?:\"NULL\")\r\n\r\na = null\r\nprintln(a?:\"NULL\")\r\n<\/pre>\n<p>\uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class='code'>\r\n10\r\nNULL\r\n<\/pre>\n<h4>!! \uc5f0\uc0b0\uc790<\/h4>\n<p>\uc774 \uc5f0\uc0b0\uc790\ub294 \uac12\uc774 null\uc77c \uc218 \uc5c6\uc73c\ub2c8 \uac71\uc815\ub9d0\uace0 \uc2e4\ud589\ud558\ub77c\ub294 \uc758\ubbf8\uc774\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"kotlin\">\r\nvar a:Int? = 10\r\nprintln(a!!.toString())\r\n\r\na = null\r\nprintln(a!!.toString())\r\n<\/pre>\n<p>\uccab\ubc88\uc9f8 \ucd9c\ub825\uc740 10\uc774\uace0, \ub450\ubc88\uc9f8\uc5d0\uc11c\ub294 \uac12\uc774 null\uc778\ub370 toString() \ud568\uc218\ub97c \ud638\ucd9c\ud558\uace0 \uc788\uc5b4 NullPointerException\uc774 \ub62d! \uc545\ubabd\uc758 \uc791\uc740 \ubd88\uc528~ \ud37d!<\/p>\n<h4>?.let{} \uad6c\ubb38<\/h4>\n<p>\uc774 \uad6c\ubb38\uc740 \uac12\uc774 null\uc774 \uc544\ub2d0 \uacbd\uc6b0 \uc5ec\ub7ec \ubb38\uc7a5\uc744 \uc2e4\ud589\ud560 \uc218 \uc788\ub294 \uad6c\ubb38\uc744 \uc81c\uacf5\ud55c\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"kotlin\">\r\nvar a:Int? = 10\r\na?.let {\r\n    println(\"The world is good place to live.\")\r\n    println(\"are you kidding me?\")\r\n}  \r\n\r\na = null\r\na?.let {\r\n    println(\"The world is good place to live.\")\r\n    println(\"I agree with you.\")\r\n}  \r\n<\/pre>\n<p>\uc2e4\ud589 \uacb0\uacfc\ub294 \ub2e4\uc74c\uacfc \uac19\ub2e4.<\/p>\n<pre class='code'>\r\nThe world is good place to live.\r\nare you kidding me?\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uc774\ubbf8 20\ub144 \ub0b4\uc678\ub85c \uac1c\ubc1c\uc790\ub4e4\uc5d0\uac8c \ud3ec\uc778\ud130\ub098 \ucc38\uc870\uc5d0 \ub300\ud55c null\uc740 \uc545\ubabd\uc774\ub77c\uace0 \ud588\ub2e4. \uc0ac\ub78c\uc740 \uc815\ud655\ud558\uac8c \uc791\ub3d9\ud558\ub294 \uae30\uacc4\uac00 \uc544\ub2c8\ubbc0\ub85c, \uadf8\ub0a0\uc758 \ucee8\ub514\uc158\uc774\ub098 \uc2a4\ud2b8\ub808\uc2a4 \ub530\uc704\ub85c \uc2e4\uc218\ub294 \uc5b8\uc81c\ub4e0 \ud560 \uc218 \uc788\ub2e4\ub294 \uc810\uc5d0\uc11c null\uc5d0 \ub300\ud55c \ucc38\uc870\ub294 \ubd84\uba85 \uc545\ubabd\uc758 \uc791\uc740 \ubd88\uc528\uc784\uc5d0\ub294 \ud2c0\ub9bc\uc774 \uc5c6\ub2e4. Kotlin\uc740 \ucc38\uc870\uc5d0 \ub300\ud55c null \uac12\uc744 \ucd5c\ub300\ud55c \ubc29\uc9c0\ud558\uace0\uc790 \uac12\uc5d0 \ub300\ud574 null \uac12\uc744 \uac00\uc9c8 \uc218 \uc788\ub294 \uacbd\uc6b0\uc640 null \uac12\uc744 \uac00\uc9c0\uc9c0 \ubabb\ud558\ub294 \uacbd\uc6b0\ub85c \ubd84\uba85\ud558\uac8c &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=10356\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;Kotlin, Null \uac80\uc0ac&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[136,1],"tags":[],"class_list":["post-10356","post","type-post","status-publish","format-standard","hentry","category-kotlin","category-uncategorized"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10356","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=10356"}],"version-history":[{"count":3,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10356\/revisions"}],"predecessor-version":[{"id":10358,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/10356\/revisions\/10358"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=10356"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=10356"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=10356"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}