{"id":516,"date":"2018-02-23T23:38:56","date_gmt":"2018-02-23T15:38:56","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/swift-if-%e8%af%ad%e5%8f%a5\/"},"modified":"2018-02-23T23:38:56","modified_gmt":"2018-02-23T15:38:56","slug":"swift-if-%e8%af%ad%e5%8f%a5","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=516","title":{"rendered":"Swift if \u8bed\u53e5"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>Swift <span class=\"color_h1\">if \u8bed\u53e5<\/span><\/h1>\n<p><a href=\"\/swift-decision-making.html\"><img decoding=\"async\" class=\"navup\" src=\"\/images\/up.gif\" alt=\"Swift \u6761\u4ef6\u8bed\u53e5\">Swift \u6761\u4ef6\u8bed\u53e5<\/a><\/p>\n<p>\u4e00\u4e2a <b>if \u8bed\u53e5<\/b> \u7531\u4e00\u4e2a\u5e03\u5c14\u8868\u8fbe\u5f0f\u540e\u8ddf\u4e00\u4e2a\u6216\u591a\u4e2a\u8bed\u53e5\u7ec4\u6210\u3002<\/p>\n<h2 class=\"tutheader\">\u8bed\u6cd5<\/h2>\n<p>Swift \u8bed\u8a00\u4e2d <b>if<\/b> \u8bed\u53e5\u7684\u8bed\u6cd5\uff1a<\/p>\n<pre>\nif boolean_expression {\n   \/* \u5982\u679c\u5e03\u5c14\u8868\u8fbe\u5f0f\u4e3a\u771f\u5c06\u6267\u884c\u7684\u8bed\u53e5 *\/\n}\n<\/pre>\n<p>\u5982\u679c\u5e03\u5c14\u8868\u8fbe\u5f0f\u4e3a <b>true<\/b>\uff0c\u5219 if \u8bed\u53e5\u5185\u7684\u4ee3\u7801\u5757\u5c06\u88ab\u6267\u884c\u3002\u5982\u679c\u5e03\u5c14\u8868\u8fbe\u5f0f\u4e3a <b>false<\/b>\uff0c\u5219 if \u8bed\u53e5\u7ed3\u675f\u540e\u7684\u7b2c\u4e00\u7ec4\u4ee3\u7801\uff08\u95ed\u62ec\u53f7\u540e\uff09\u5c06\u88ab\u6267\u884c\u3002<\/p>\n<h2 class=\"tutheader\">\u6d41\u7a0b\u56fe<\/h2>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2014\/09\/if_statement.jpg\" alt=\"C \u4e2d\u7684 if \u8bed\u53e5\"><\/p>\n<h2 class=\"tutheader\">\u5b9e\u4f8b<\/h2>\n<pre>\nimport Cocoa\n\nvar varA:Int = 10;\n\n\/* \u68c0\u6d4b\u6761\u4ef6 *\/\nif varA &lt; 20 {\n    \/* \u5982\u679c\u6761\u4ef6\u8bed\u53e5\u4e3a true \u6267\u884c\u4ee5\u4e0b\u7a0b\u5e8f *\/\n    print(\"varA \u5c0f\u4e8e 20\");\n}\nprint(\"varA \u53d8\u91cf\u7684\u503c\u4e3a \\(varA)\");\n<\/pre>\n<p>\u5f53\u4e0a\u9762\u7684\u4ee3\u7801\u88ab\u7f16\u8bd1\u548c\u6267\u884c\u65f6\uff0c\u5b83\u4f1a\u4ea7\u751f\u4e0b\u5217\u7ed3\u679c\uff1a<\/p>\n<pre>\nvarA \u5c0f\u4e8e 20\nvarA \u53d8\u91cf\u7684\u503c\u4e3a 10\n<\/pre>\n<p><a href=\"\/swift-decision-making.html\"><img decoding=\"async\" class=\"navup\" src=\"\/images\/up.gif\" alt=\"Swift \u6761\u4ef6\u8bed\u53e5\">Swift \u6761\u4ef6\u8bed\u53e5<\/a><\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">Swift if \u8bed\u53e5 Swift \u6761\u4ef6\u8bed\u53e5 \u4e00\u4e2a if \u8bed\u53e5 \u7531\u4e00\u4e2a\u5e03\u5c14\u8868\u8fbe\u5f0f\u540e\u8ddf\u4e00\u4e2a\u6216&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=516\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26,28],"tags":[74,119],"class_list":["post-516","post","type-post","status-publish","format-standard","hentry","category-mobile","category-swift","tag-ios","tag-swift","zoom-theme-has-thumb"],"_links":{"self":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/516","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=516"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/516\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=516"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=516"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=516"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}