{"id":6714,"date":"2020-03-18T14:27:02","date_gmt":"2020-03-18T06:27:02","guid":{"rendered":"https:\/\/www.linuxcool.com\/?p=6714"},"modified":"2020-05-23T21:27:10","modified_gmt":"2020-05-23T13:27:10","slug":"return","status":"publish","type":"post","link":"https:\/\/www.linuxcool.com\/return","title":{"rendered":"return\u547d\u4ee4 – \u4ece\u51fd\u6570\u4e2d\u9000\u51fa\u5e76\u8fd4\u56de\u6570\u503c"},"content":{"rendered":"\n

return\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4f7f\u5f97shell\u51fd\u6570\u9000\u51fa\u5e76\u8fd4\u56de\u6570\u503c\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9an\u7684\u503c\uff0c\u5219\u9ed8\u8ba4\u4e3a\u51fd\u6570\u6700\u540e\u4e00\u6761\u547d\u4ee4\u6267\u884c\u7684\u8fd4\u56de\u72b6\u6001\u3002<\/p>\n\n\n\n

\u8fd4\u56de\u503c\u4e3a\u4f60\u6307\u5b9a\u7684\u53c2\u6570n\u7684\u503c\uff0c\u5982\u679c\u4f60\u6307\u5b9a\u7684\u53c2\u6570\u5927\u4e8e255\u6216\u5c0f\u4e8e0\uff0c\u90a3\u4e48\u4f1a\u901a\u8fc7\u52a0\u6216\u51cf256\u7684\u65b9\u5f0f\u4f7f\u5f97\u8fd4\u56de\u503c\u603b\u662f\u5904\u4e8e0\u5230255\u4e4b\u95f4\u3002\u5728\u51fd\u6570\u5916\u6267\u884creturn\u8bed\u53e5\u4f1a\u8fd4\u56de\u5931\u8d25\u3002<\/p>\n\n\n\n

\u5c31bash\u800c\u8a00, return\u547d\u4ee4\u53ea\u80fd\u7528\u5728\u51fd\u6570\u4e2d\uff0c\u4e0d\u80fd\u76f4\u63a5\u7528\u5728\u811a\u672c\u4e2d<\/p>\n\n\n\n

\u5185\u7f6e\u547d\u4ee4return\u7528\u4e8e\u4ece\u51fd\u6570\u4e2d\u8fd4\u56de, return\u547d\u4ee4\u5728\u51fd\u6570\u4e2d\u4e0d\u662f\u5fc5\u987b\u7684\uff0c\u51fd\u6570\u88ab\u8c03\u7528\u65f6\uff0c\u51fd\u6570\u5185\u7684\u547d\u4ee4\u6267\u884c\u5b8c\u6210\u540e\u81ea\u7136\u4f1a\u8fd4\u56de\u5230\u8c03\u7528\u5b83\u7684\u5730\u65b9\uff08\u4e00\u822c\u662f\u8fd4\u56de\u5230\u4e3b\u7a0b\u5e8f\uff09\u3002\u5982\u679c\u67d0\u51fd\u6570\u4e2d\u6709return\u547d\u4ee4\uff0c\u6267\u884c\u5230return\u65f6\u5c31\u8fd4\u56de\u3002\u5982\u679creturn\u5728\u51fd\u6570\u4e2d\u4e0d\u662f\u6700\u540e\u4e00\u6761\u547d\u4ee4\uff0c\u90a3\u4e48return\u540e\u9762\u7684\u5176\u4ed6\u547d\u4ee4\u4e0d\u518d\u6267\u884c\u3002<\/p>\n\n\n\n

\u8bed\u6cd5\u683c\u5f0f:<\/strong> return [\u53c2\u6570]<\/p>\n\n\n\n

\u5e38\u7528\u53c2\u6570\uff1a<\/strong><\/p>\n\n\n\n

n<\/td>\u6574\u6570<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n

\u53c2\u8003\u5b9e\u4f8b<\/strong><\/p>\n\n\n\n

\u5b9a\u4e49\u4e00\u4e2a\u8fd4\u56de\u503c\u5927\u4e8e255\u7684\u51fd\u6570\uff1a<\/p>\n\n\n\n

[root@linuxcool ~]# example() {return 259}\n\/\/ \u6267\u884c\u51fd\u6570\n[root@linuxcool ~]# example\n\/\/ \u663e\u793a3\n[root@linuxcool ~]# echo $?\n3 <\/pre>\n\n\n\n

\u7acb\u5373\u7ed3\u675f\u672cprocedure\u7684\u6267\u884c\uff1a<\/p>\n\n\n\n

Procedure checkstatus\nParameter name\nif len(name) = 0 then\nreturn\nelse\n?name\nendif\nmessagebox('hello')\nendproc<\/pre>\n\n\n\n

\u5728\u5177\u6709\u5bf9\u8c61\u5f15\u7528\u8fd4\u56de\u7c7b\u578b\u7684\u65b9\u6cd5\u4e2d\u8fd4\u56denull\uff1a<\/p>\n\n\n\n

public Button doStuff\uff08\uff09{\nreturn null\uff1b\n}<\/pre>\n","protected":false},"excerpt":{"rendered":"

return\u547d\u4ee4\u7684\u4f5c\u7528\u662f\u4f7f\u5f97shell\u51fd\u6570\u9000\u51fa\u5e76\u8fd4\u56de\u6570\u503c\uff0c\u5982\u679c\u6ca1\u6709\u6307\u5b9an\u7684\u503c\uff0c\u5219\u9ed8\u8ba4\u4e3a\u51fd\u6570\u6700\u540e\u4e00\u6761\u547d\u4ee4\u6267\u884c\u7684\u8fd4 […]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"_links":{"self":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/6714"}],"collection":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/comments?post=6714"}],"version-history":[{"count":6,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/6714\/revisions"}],"predecessor-version":[{"id":7371,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/posts\/6714\/revisions\/7371"}],"wp:attachment":[{"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/media?parent=6714"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/categories?post=6714"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.linuxcool.com\/wp-json\/wp\/v2\/tags?post=6714"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}