{"id":525,"date":"2018-02-23T23:38:59","date_gmt":"2018-02-23T15:38:59","guid":{"rendered":"http:\/\/60.205.208.74\/2018\/02\/23\/swift-repeatwhile-%e5%be%aa%e7%8e%af\/"},"modified":"2018-02-23T23:38:59","modified_gmt":"2018-02-23T15:38:59","slug":"swift-repeatwhile-%e5%be%aa%e7%8e%af","status":"publish","type":"post","link":"https:\/\/www.puzi7.net\/?p=525","title":{"rendered":"Swift repeat\u2026while \u5faa\u73af"},"content":{"rendered":"<span itemprop=\"description\"><div class=\"article-body\">\n<div class=\"article-intro\" id=\"content\">\n<h1>Swift repeat&#8230;while \u5faa\u73af<\/h1>\n<p><a href=\"\/swift-loops.html\"><img decoding=\"async\" class=\"navup\" src=\"\/images\/up.gif\" alt=\"Swift \u5faa\u73af\">Swift \u5faa\u73af<\/a><\/p>\n<p>Swift repeat&#8230;while \u5faa\u73af\u4e0d\u50cf for \u548c while \u5faa\u73af\u5728\u5faa\u73af\u4f53\u5f00\u59cb\u6267\u884c\u524d\u5148\u5224\u65ad\u6761\u4ef6\u8bed\u53e5\uff0c\u800c\u662f\u5728\u5faa\u73af\u6267\u884c\u7ed3\u675f\u65f6\u5224\u65ad\u6761\u4ef6\u662f\u5426\u7b26\u5408\u3002<\/p>\n<h3>\u8bed\u6cd5<\/h3>\n<p>Swift repeat&#8230;while \u5faa\u73af\u7684\u8bed\u6cd5\u683c\u5f0f\u5982\u4e0b\uff1a<\/p>\n<pre>\nrepeat\n{\n   statement(s);\n}while( condition );\n<\/pre>\n<p>\u8bf7\u6ce8\u610f\uff0c\u6761\u4ef6\u8868\u8fbe\u5f0f\u51fa\u73b0\u5728\u5faa\u73af\u7684\u5c3e\u90e8\uff0c\u6240\u4ee5\u5faa\u73af\u4e2d\u7684 statement(s) \u4f1a\u5728\u6761\u4ef6\u88ab\u6d4b\u8bd5\u4e4b\u524d\u81f3\u5c11\u6267\u884c\u4e00\u6b21\u3002<\/p>\n<p>\u5982\u679c\u6761\u4ef6\u4e3a true\uff0c\u63a7\u5236\u6d41\u4f1a\u8df3\u8f6c\u56de\u4e0a\u9762\u7684 repeat\uff0c\u7136\u540e\u91cd\u65b0\u6267\u884c\u5faa\u73af\u4e2d\u7684 statement(s)\u3002\u8fd9\u4e2a\u8fc7\u7a0b\u4f1a\u4e0d\u65ad\u91cd\u590d\uff0c\u76f4\u5230\u7ed9\u5b9a\u6761\u4ef6\u53d8\u4e3a false \u4e3a\u6b62\u3002<\/p>\n<p>\u6570\u5b57 0, \u5b57\u7b26\u4e32 &#8216;0&#8217; \u548c &#8220;&#8221;, \u7a7a\u7684 list(), \u53ca\u672a\u5b9a\u4e49\u7684\u53d8\u91cf\u90fd\u4e3a <b>false<\/b> \uff0c\u5176\u4ed6\u7684\u5219\u90fd\u4e3a <b>true<\/b>\u3002true \u53d6\u53cd\u4f7f\u7528 <b>!<\/b> \u53f7\u6216 <b>not<\/b>\uff0c\u53d6\u53cd\u540e\u8fd4\u56de false\u3002<\/p>\n<p><b>\u6d41\u7a0b\u56fe\uff1a<\/b><\/p>\n<p><img decoding=\"async\" src=\"http:\/\/www.runoob.com\/wp-content\/uploads\/2015\/11\/swift_repeat_while_loop.jpg\"><\/p>\n<h3>\u5b9e\u4f8b<\/h3>\n<pre>\nimport Cocoa\n\nvar index = 15\n\nrepeat{\n    print( \"index \u7684\u503c\u4e3a \\(index)\")\n    index = index + 1\n}while index &lt; 20\n<\/pre>\n<p>\u4ee5\u4e0a\u7a0b\u5e8f\u6267\u884c\u8f93\u51fa\u7ed3\u679c\u4e3a\uff1a<\/p>\n<pre>\nindex \u7684\u503c\u4e3a 15\nindex \u7684\u503c\u4e3a 16\nindex \u7684\u503c\u4e3a 17\nindex \u7684\u503c\u4e3a 18\nindex \u7684\u503c\u4e3a 19\n\n<\/pre>\n<p><a href=\"\/swift-loops.html\"><img decoding=\"async\" class=\"navup\" src=\"\/images\/up.gif\" alt=\"Swift \u5faa\u73af\">Swift \u5faa\u73af<\/a><\/p>\n<\/p><\/div>\n<\/p><\/div>\n<span>","protected":false},"excerpt":{"rendered":"<p class=\"excerpt\"><span itemprop=\"description\">Swift repeat&#8230;while \u5faa\u73af Swift \u5faa\u73af Swift re&hellip;<\/span><\/p>\n<p class=\"more-link-p btn-align-right\"><a class=\"green zoom-btn\" href=\"https:\/\/www.puzi7.net\/?p=525\">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-525","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\/525","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=525"}],"version-history":[{"count":0,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=\/wp\/v2\/posts\/525\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.puzi7.net\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}