{"id":39,"date":"2019-04-26T14:31:47","date_gmt":"2019-04-26T05:31:47","guid":{"rendered":"https:\/\/kotlin.tecc0.com\/?p=39"},"modified":"2019-04-26T14:32:46","modified_gmt":"2019-04-26T05:32:46","slug":"post-39","status":"publish","type":"post","link":"https:\/\/kotlin.tecc0.com\/?p=39","title":{"rendered":"Kotlin\u3067\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u30c1\u30a7\u30fc\u30f3(Optional Chaining)\u3092\u4f7f\u3046\u65b9\u6cd5"},"content":{"rendered":"\n<p>Java\u306a\u3093\u304b\u3067\u306f\u306a\u304b\u3063\u305f\u6982\u5ff5\u306a\u306e\u3067\u65b0\u3057\u304f\u899a\u3048\u3088\u3046\u3002<\/p>\n<p>\u00a0<\/p>\n<pre class=\"lang:default decode:true\">var str: String? = null\n\nif (str != null) {\n    str.toInt() \/\/ null\u30c1\u30a7\u30c3\u30af\u3057\u3066\u308b\u306e\u3067\u5b9f\u884c\u3055\u308c\u306a\u3044\n}\n\nstr!!.toInt() \/\/ \u843d\u3061\u308b\n\nstr?.toInt() \/\/ \u843d\u3061\u306a\u3044(toInt()\u304c\u5b9f\u884c\u3055\u308c\u306a\u3044<\/pre>\n<p>\u3053\u3093\u306a\u611f\u3058\u3067 <code>!!<\/code>\u00a0\u3092\u4f7f\u3046\u3068\u3001null\u304c\u5165\u3063\u3066\u3044\u308b\u5834\u5408\u306b\u843d\u3061\u3066\u3057\u307e\u3046\u3002<\/p>\n<p>Java\u306e\u3088\u3046\u306bnull\u30c1\u30a7\u30c3\u30af\u3092\u3059\u308b\u3068if\u6587\u306e\u4e2d\u304c\u5b9f\u884c\u3055\u308c\u306a\u3044\u306e\u3067\u843d\u3061\u306a\u3044\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u305d\u308c\u3092kotlin\u3067\u306f `\u300c\u5909\u6570?.\u30e1\u30bd\u30c3\u30c9\u300d` \u306e\u5f62\u3067\u66f8\u304f\u3053\u3068\u3067\u3001null\u3060\u3063\u305f\u5834\u5408\u306b\u5f8c\u308d\u306b\u7d9a\u304f\u30e1\u30bd\u30c3\u30c9\u3092\u5b9f\u884c\u3057\u306a\u3044\u3068\u3044\u3046\u66f8\u304d\u65b9\u304c\u53ef\u80fd\u3067\u3042\u308b\u3002(\u3053\u308c\u304cOptional Chaining\u3068\u547c\u3070\u308c\u308b<\/p>\n<p>\u00a0<\/p>\n<p>null\u30c1\u30a7\u30c3\u30af\u3092\u3059\u308b\u66f8\u304d\u65b9\u3067\u3082\u554f\u984c\u306f\u306a\u3044\u304c\u3001kotlin\u3067\u306f<strong>Optional Chaining<\/strong>\u304c\u4e00\u822c\u7684\u306a\u306e\u3067\u7a4d\u6975\u7684\u306b\u4f7f\u3063\u3066\u3044\u304f\u3053\u3068\u306b\u3057\u3088\u3046\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u3082\u3061\u308d\u3093Java\u7684\u306anull\u30c1\u30a7\u30c3\u30af\u3092\u4f7f\u3063\u3066\u306f\u3044\u3051\u306a\u3044\u308f\u3051\u3067\u306f\u306a\u3044\u306e\u3067\u3001\u53ef\u8aad\u6027\u306a\u3069\u4f55\u304b\u7406\u7531\u304c\u3042\u308b\u5834\u5408\u306f\u4f7f\u3063\u3066\u3044\u3053\u3046\u3002<\/p>\n<p>\u00a0<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Java\u306a\u3093\u304b\u3067\u306f\u306a\u304b\u3063\u305f\u6982\u5ff5\u306a\u306e\u3067\u65b0\u3057\u304f\u899a\u3048\u3088\u3046\u3002 \u00a0 var str: String? = null if (str != null) { str.toInt() \/\/ null\u30c1\u30a7\u30c3\u30af\u3057\u3066\u308b\u306e\u3067\u5b9f\u884c\u3055\u308c\u306a\u3044 } s [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/39"}],"collection":[{"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=39"}],"version-history":[{"count":4,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions"}],"predecessor-version":[{"id":49,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/39\/revisions\/49"}],"wp:attachment":[{"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=39"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=39"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=39"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}