{"id":31,"date":"2019-04-18T15:10:28","date_gmt":"2019-04-18T06:10:28","guid":{"rendered":"https:\/\/kotlin.tecc0.com\/?p=31"},"modified":"2019-04-18T16:40:00","modified_gmt":"2019-04-18T07:40:00","slug":"31","status":"publish","type":"post","link":"https:\/\/kotlin.tecc0.com\/?p=31","title":{"rendered":"Kotlin\u3067\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u578b(Optional)\u306e\u5909\u6570\u3092\u6271\u3046\u65b9\u6cd5"},"content":{"rendered":"\n<p>Kotlin\u306b\u306f<strong>\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u578b(Optional)<\/strong>\u3068\u3044\u3046\u8003\u3048\u65b9\u304c\u3042\u308a\u3001\u3053\u308c\u306f<strong>\u5024\u304c\u7a7a\u3067\u3042\u308b(null)\u3092\u8a31\u5bb9\u3059\u308b<\/strong>\u304b\u3069\u3046\u304b\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002<\/p>\n<p>\u00a0<\/p>\n<h3>Kotlin\u3067\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u5909\u6570\u3092\u5b9a\u7fa9\u30fb\u5ba3\u8a00\u3059\u308b\u65b9\u6cd5<\/h3>\n<pre class=\"lang:default decode:true\">\/\/ null\u3092\u8a31\u5bb9\u3057\u306a\u3044\nvar str: String\n\/\/ null\u3092\u8a31\u5bb9\u3059\u308b\nvar str2: String?\n \n\/\/ \u30a8\u30e9\u30fc\u306b\u306a\u308b\n\/\/ str = null\n\/\/ \u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\nstr2 = null\n \n\/\/ null\u3092\u8a31\u5bb9\u3057\u3066\u521d\u671f\u5316\nvar str3: String? = null\n\/\/ \u3053\u3061\u3089\u3067\u3082\u521d\u671f\u5024\u306fnull\u306b\u306a\u3063\u3066\u3044\u308b\nvar str4: String?<\/pre>\n<p>\u3053\u306e\u3088\u3046\u306b null \u3092\u8a31\u5bb9\u3059\u308b\u5834\u5408\u306f\u3001<strong>\u578b\u540d\u306e\u3042\u3068\u306b ?<\/strong> \u3092\u3064\u3051\u3066\u3042\u3052\u308b\u5fc5\u8981\u304c\u3042\u308b\u3002<\/p>\n<p>\u3082\u3061\u308d\u3093\u3001\u4e00\u756a\u4e0b\u306e\u3088\u3046\u306bnull\u3067\u521d\u671f\u5316\u3059\u308b\u3053\u3068\u3082\u53ef\u80fd\u3002<\/p>\n<p>\u00a0<\/p>\n<h3>\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u5909\u6570\u3092\u30a2\u30f3\u30e9\u30c3\u30d7(unwrap)\u3059\u308b<\/h3>\n<p>\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u5909\u6570\u306f\u901a\u5e38\u306e\u5909\u6570\u3068\u7570\u306a\u308b\u3002\u306e\u3067\u3001\u901a\u5e38\u306e\u5909\u6570\u3068\u540c\u3058\u3088\u3046\u306b\u6271\u3046\u5834\u5408\u306f<strong>\u30a2\u30f3\u30e9\u30c3\u30d7<\/strong>\u3068\u3044\u3046\u4e00\u624b\u9593\u304c\u5fc5\u8981\u306b\u306a\u308b\u3002<\/p>\n<pre class=\"lang:default decode:true \">fun main() {\n    var str: String = \"hoge\"\n    var str2: String? = \"hoge\"\n\n    \/\/ \u30a8\u30e9\u30fc\u306b\u306a\u308b\n    \/\/ str = null\n    str2 = null\n\n    print(str2)\n    print(str2!!)\n\n    \/\/ \u30a8\u30e9\u30fc\u306b\u306a\u308b\n    \/\/ fuga(str2)\n    \/\/ \u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\n    fuga(str2!!)\n    \/\/ \u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\n    moe(str2)\n}\n\nprivate fun fuga(str: String) {\n    \/\/ Some Action\n}\n\nprivate fun moe(str: String?) {\n    \/\/ Some Action\n}<\/pre>\n<p>\u3061\u3087\u3063\u3068\u307e\u3060\u30e1\u30bd\u30c3\u30c9\u306a\u3069\u306b\u3064\u3044\u3066\u8aac\u660e\u3057\u3066\u306a\u3044\u304c\u3001String\u306b?\u304c\u3064\u3044\u3066\u3044\u306a\u3044fuga()\u3067\u306f\u30a8\u30e9\u30fc\u306b\u306a\u308a\u3001moe()\u3067\u306f\u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u3044\u3002<\/p>\n<p>\u3053\u308c\u306fwrap\u3055\u308c\u305f\u5909\u6570\u3068wrap\u3055\u308c\u3066\u3044\u306a\u3044\u5909\u6570\u304c\u660e\u78ba\u306b\u533a\u5225\u3055\u308c\u3066\u3044\u308b\u305f\u3081\u3060\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u307e\u305f <code>!!<\/code>\u00a0\u3092\u4f7f\u3046\u3053\u3068\u3067wrap\u3092\u53d6\u308a\u5916\u3059(unwrap)\u3059\u308b\u3053\u3068\u304c\u3067\u304d\u308b\u306e\u3067\u3001\u305d\u306e\u72b6\u614b\u306b\u3059\u308c\u3070fuga()\u3082\u30a8\u30e9\u30fc\u306b\u306a\u3089\u306a\u304f\u306a\u308b\u3002<\/p>\n<p>\u00a0<\/p>\n<p>\u3057\u304b\u3057\u3001unwrap(!!)\u306f\u5f37\u5236unwrap\u3068\u3082\u547c\u3070\u308c\u3001\u5931\u6557\u3057\u305f\u3068\u304d\u306b\u30a8\u30e9\u30fc\u3067\u3001\u6700\u60aa\u30a2\u30d7\u30ea\u304c\u5f37\u5236\u7d42\u4e86\u3057\u3066\u3057\u307e\u3046\u306a\u3069\u306e\u5f0a\u5bb3\u304c\u3042\u308b\u305f\u3081\u3001\u591a\u7528\u306f\u304a\u3059\u3059\u3081\u3067\u304d\u306a\u3044\u3002<\/p>\n<p><strong>\u5b89\u5168\u306b\u30a2\u30f3\u30e9\u30c3\u30d7<\/strong>\u3059\u308b\u65b9\u6cd5\u306f\u5f8c\u306b\u66f8\u304f\u3053\u3068\u3068\u3059\u308b\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Kotlin\u306b\u306f\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u578b(Optional)\u3068\u3044\u3046\u8003\u3048\u65b9\u304c\u3042\u308a\u3001\u3053\u308c\u306f\u5024\u304c\u7a7a\u3067\u3042\u308b(null)\u3092\u8a31\u5bb9\u3059\u308b\u304b\u3069\u3046\u304b\u3092\u6307\u5b9a\u3067\u304d\u307e\u3059\u3002 \u00a0 Kotlin\u3067\u30aa\u30d7\u30b7\u30e7\u30ca\u30eb\u5909\u6570\u3092\u5b9a\u7fa9\u30fb\u5ba3\u8a00\u3059\u308b\u65b9\u6cd5 \/\/ null\u3092\u8a31\u5bb9\u3057\u306a\u3044  [&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\/31"}],"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=31"}],"version-history":[{"count":6,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions"}],"predecessor-version":[{"id":38,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=\/wp\/v2\/posts\/31\/revisions\/38"}],"wp:attachment":[{"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=31"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=31"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kotlin.tecc0.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=31"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}