{"id":267,"date":"2017-05-31T21:23:45","date_gmt":"2017-05-31T12:23:45","guid":{"rendered":"https:\/\/do-gugan.com\/swift\/?p=267"},"modified":"2017-05-31T21:31:24","modified_gmt":"2017-05-31T12:31:24","slug":"%e6%9d%a1%e4%bb%b6%e5%88%86%e5%b2%90%e3%82%b3%e3%83%bc%e3%83%89-5-%e9%96%a2%e6%95%b0%e3%82%92%e3%81%98%e3%82%87%e3%81%86%e3%81%9a%e3%81%ab%e4%bd%bf%e3%81%86","status":"publish","type":"post","link":"https:\/\/do-gugan.com\/swift\/?p=267","title":{"rendered":"\u6761\u4ef6\u5206\u5c90\u30b3\u30fc\u30c9 5. \u95a2\u6570\u3092\u3058\u3087\u3046\u305a\u306b\u4f7f\u3046"},"content":{"rendered":"<p>\u4eca\u307e\u3067\u5b66\u3093\u3060\u95a2\u6570\uff08func\uff09\u3001\u30eb\u30fc\u30d7\uff08for\uff09\u3001\u6761\u4ef6\u5206\u5c90\uff08if\uff09\u3092\u99c6\u4f7f\u3057\u3066\u30b9\u30c6\u30fc\u30b8\u3092\u653b\u7565\u3057\u307e\u3059\u3002<br \/>\n\u6700\u521d\u306bbyte\u541b\u304c\u3044\u308b\u65b9\u3092\u624b\u524d\u3001\u5411\u3044\u3066\u3044\u308b\u65b9\u3092\u5965\u3068\u3057\u307e\u3059\u3002\u6700\u521d\u306b\u7a81\u304d\u5f53\u305f\u308a\u307e\u3067\u9032\u3080\u306e\u3092A\u533a\u9593\u3001\u5de6\u306e\u968e\u6bb5\u3092\u964d\u308a\u3066\u632f\u308a\u8fd4\u3063\u3066\u304b\u3089\u3001\u307e\u305f\u624b\u524d\u306b\u623b\u308b\u307e\u3067\u3092B\u533a\u9593\u3001\u3055\u3089\u306b\u632f\u308a\u8fd4\u3063\u3066\u518d\u3073\u5965\u3078\u884c\u304f\u306e\u3092C\u533a\u9593\u3068\u547c\u3073\u307e\u3057\u3087\u3046\u3002<br \/>\n\u307e\u305a\u30b9\u30c6\u30c3\u30d71\u306b\u6307\u793a\u3055\u308c\u308bcollectOrToggle()\u95a2\u6570\u3092\u4f5c\u6210\u3057\u307e\u3059\u3002\u540d\u524d\u306e\u901a\u308a\u300c\u5b9d\u77f3\u304c\u3042\u308c\u3070\u53d6\u308a\u3001\u9589\u30b9\u30a4\u30c3\u30c1\u306a\u3089\u5207\u308a\u66ff\u3048\u308b\u300d\u95a2\u6570\u3067\u3059\u30022\u30b3\u30de\u304a\u304d\u306b\u3069\u3061\u3089\u304b\u304c\u51fa\u73fe\u3059\u308b\u306e\u3067\u305d\u306e\u524d\u9032\u90e8\u5206\u3082\u542b\u3081\u3066\u3057\u307e\u3063\u3066\u300c1\u533a\u9593\u3092\u51e6\u7406\u3059\u308b\u300d\u95a2\u6570\u3068\u3057\u3066\u307f\u307e\u3057\u305f\u3002<\/p>\n<pre class=\"lang:swift decode:true \" >\r\n\/\/\u624b\u524d->\u5965\u307e\u305f\u306f\u5965->\u624b\u524d\u306e1\u5217\u3092\u51e6\u7406\u3059\u308b\u95a2\u6570\r\nfunc collectOrToggle {\r\n    for i in 1 ... 2 {\r\n        moveForward()\r\n        moveForward()\r\n        if isOnGem {\r\n            collectGem()\r\n        } else if isOnClosedSwitch {\r\n            toggleSwitch()\r\n        }\r\n    }\r\n}\r\n\r\n\/\/\u3053\u3053\u304b\u3089\u672c\u7de8\r\ncollectOrToggle() \/\/A\u533a\u9593\u3092\u51e6\u7406\r\nturnLeft()\r\nmoveForward()\r\nmoveForward()\r\nturnLeft()\r\ncollectOrToggle() \/\/B\u533a\u9593\u3092\u51e6\u7406\r\nturnRight()\r\nmoveForward()\r\nturnRight()\r\ncollectOrToggle() \/\/C\u533a\u9593\u3092\u51e6\u7406\r\n<\/pre>\n<p>6\u884c\u76ee\u304b\u3089\u306eif\u6587\u3067\u306f\u300c\u5b9d\u77f3\u304c\u3042\u3063\u305f\u3089\u53d6\u308b\u300d\u3068\u300c\u9589\u30b9\u30a4\u30c3\u30c1\u306a\u3089\u5207\u308a\u66ff\u3048\u308b\u300d\u306e2\u3064\u306e\u6761\u4ef6\u5206\u5c90\u3092else if\u3092\u3064\u304b\u3063\u30661\u3064\u306b\u307e\u3068\u3081\u3066\u3044\u307e\u3059\u3002<\/p>\n<pre class=\"start-line:6 lang:swift decode:true \" >\r\n        if isOnGem {\r\n            collectGem()\r\n        } else if isOnClosedSwitch {\r\n            toggleSwitch()\r\n        }\r\n<\/pre>\n<p>\u3082\u3061\u308d\u3093\u3001\u2193\u306e\u3088\u3046\u306b2\u3064\u306e\u72ec\u7acb\u3057\u305fif\u6587\u306b\u3057\u3066\u3082\u69cb\u3044\u307e\u305b\u3093\u3002<\/p>\n<pre class=\"start-line:6 lang:swift decode:true \" >\r\n        if isOnGem {\r\n            collectGem()\r\n        }\r\n        if isOnClosedSwitch {\r\n            toggleSwitch()\r\n        }\r\n<\/pre>\n<p>\u305f\u3060\u3053\u306e\u30b9\u30c6\u30fc\u30b8\u3067\u306f1\u3064\u306e\u30b3\u30de\u306b\u5b9d\u77f3\u3068\u30b9\u30a4\u30c3\u30c1\u304c\u540c\u6642\u306b\u51fa\u308b\u3053\u3068\u306f\u591a\u5206\u306a\u3055\u305d\u3046\u306a\u306e\u3067\u3001else if\u306b\u3057\u3066\u304a\u304f\u3068\u3001\u5b9d\u77f3\u304c\u3067\u305f\u6642\u70b9\u3067\u30b9\u30a4\u30c3\u30c1\u304c\u3042\u308b\u304b\u3069\u3046\u304b\u306e\u5224\u65ad\u51e6\u7406\u306f\u3057\u306a\u304f\u306a\u308a\u3001\u307b\u3093\u306e\u3061\u3087\u3063\u3068\u3060\u3051\u5b9f\u884c\u3092\u901f\u304f\u3067\u304d\u308b\u53ef\u80fd\u6027\u304c\u3042\u308a\u307e\u3059\u3002<\/p>\n<script type=\"text\/javascript\">amzn_assoc_ad_type =\"responsive_search_widget\"; amzn_assoc_tracking_id =\"doguganprojec-22\"; amzn_assoc_marketplace =\"amazon\"; amzn_assoc_region =\"JP\"; amzn_assoc_placement =\"\"; amzn_assoc_search_type = \"search_widget\";amzn_assoc_width =\"500\"; amzn_assoc_height =\"400\"; amzn_assoc_default_search_category =\"\"; amzn_assoc_default_search_key =\"iPad\";amzn_assoc_theme =\"light\"; amzn_assoc_bg_color =\"FFFFFF\"; <\/script><script src=\"\/\/z-fe.amazon-adsystem.com\/widgets\/q?ServiceVersion=20070822&Operation=GetScript&ID=OneJS&WS=1&Marketplace=JP\"><\/script>","protected":false},"excerpt":{"rendered":"<p>\u4eca\u307e\u3067\u5b66\u3093\u3060\u95a2\u6570\uff08func\uff09\u3001\u30eb\u30fc\u30d7\uff08for\uff09\u3001\u6761\u4ef6\u5206\u5c90\uff08if\uff09\u3092\u99c6\u4f7f\u3057\u3066\u30b9\u30c6\u30fc\u30b8\u3092\u653b\u7565\u3057\u307e\u3059\u3002 \u6700\u521d\u306bbyte\u541b\u304c\u3044\u308b\u65b9\u3092\u624b\u524d\u3001\u5411\u3044\u3066\u3044\u308b\u65b9\u3092\u5965\u3068\u3057\u307e\u3059\u3002\u6700\u521d\u306b\u7a81\u304d\u5f53\u305f\u308a\u307e\u3067\u9032\u3080\u306e\u3092A\u533a\u9593\u3001\u5de6\u306e\u968e\u6bb5\u3092\u964d\u308a\u3066\u632f\u308a\u8fd4\u3063\u3066\u304b &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/do-gugan.com\/swift\/?p=267\" class=\"more-link\"><span class=\"screen-reader-text\">&#8220;\u6761\u4ef6\u5206\u5c90\u30b3\u30fc\u30c9 5. \u95a2\u6570\u3092\u3058\u3087\u3046\u305a\u306b\u4f7f\u3046&#8221; \u306e<\/span>\u7d9a\u304d\u3092\u8aad\u3080<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,8],"tags":[],"class_list":["post-267","post","type-post","status-publish","format-standard","hentry","category-learncode1","category-ifthen"],"_links":{"self":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/267","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=267"}],"version-history":[{"count":5,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions"}],"predecessor-version":[{"id":272,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=\/wp\/v2\/posts\/267\/revisions\/272"}],"wp:attachment":[{"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=267"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=267"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/do-gugan.com\/swift\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=267"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}