- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
第三章控制结构
Chapter 3, Control Structures
(第三章,控制结构)
In this chapter all the control structures in Pike will be explained. As mentioned earlier, control structures are used to control the flow of the program execution. Note that functions that make the program pause and simple function calls are not qualified as control structures.
(在这一章中所有在Pike中的控制结构都将会被解释。如前面所提到的,控制结构被用来控制程序运行的流程。注意那些方法会使程序中止并用简单的函数不能访问控制结构。)
3.1 Conditions(条件)
Pike only has two major condition control structures. We have already seen examples of both of them in Chapter two. But for completeness they will be described again in this chapter.
(Pike只有两个主要条件的控制结构。我们在前两章中已经看到关于它们两个的例子。要不是之前已经很完整地描述过在这一章中它们还会再次被解释。)
3.1.1 if
The simplest one is called the if statement. It can be written anywhere where a statement is expected and it looks like this:
(最简单的是被称作if的条件语句。它可以像这样被写在任何地方:)
if( expression ) statement1; else statement2;
if(表达式) 语句1; else 语句2;
Please note that there is no semicolon after the parenthesis or after the else. Step by step, if does the following:
(请注意在圆括号之后或者else后没有分号。一步一步地,像下面这样:)
First it evaluates expression.
If the result was false go to point 5.
Execute statement1.
Jump to point 6.
Execute statement2.
Done.
首先计算表达式。
如果结果是false就到第5步。
执行语句1。
跳到第6步。
执行语句2。
完成。
This is actually more or less how the interpreter executes the if statement. In short, statement1 is executed if expression is true otherwise statement2 is executed. If you are interested in having something executed if the expression is false you can drop the whole else part like this:
(执行if语句实际上可以或多或少。简单地说,如果表达式的结果是true就执行语句1,否则就执行语句2。如果你对执行if语句的结果是false比较感兴趣,你可以终止所有else部分,像这样:)
if( expression )????statement1;
if(表达式)
语句1;
If on the other hand you are not interested in evaluating something if the expression is false you should use the not operator to negate the true/false value of the expression. See chapter 5 for more information about the not operator. It would look like this:
(如果从另一方面来说,你并不对if的表达式结果是false感兴趣,你可以使用否
您可能关注的文档
最近下载
- 22J403-1 楼梯 栏杆 栏板(一) (3).pdf VIP
- 口腔科门诊护士接诊流程ppt新版【16页】.pptx VIP
- 课件:土壤有机质的测定.ppt VIP
- 2025年蜀道投资集团有限责任公司招聘笔试备考试题及答案解析.docx VIP
- 材料与试验协会 E 3-2001金相试样的制备方法(中文版).pdf VIP
- 设备台账标准格式.xls VIP
- 动火作业施工方案模板.docx
- 玩家国度ROG STRIX Z790-E GAMING WIFI 主板 ROG STRIX Z790-E GAMING WIFI 简体中文版使用手册.pdf
- 2025年蜀道投资集团有限责任公司招聘笔试备考题库及一套答案详解.docx
- 2025年辅警招考时事政治考题及答案.docx VIP
文档评论(0)