Chinaunix首页 | 论坛 | 博客
  • 博客访问: 71845
  • 博文数量: 14
  • 博客积分: 570
  • 博客等级: 中士
  • 技术积分: 153
  • 用 户 组: 普通用户
  • 注册时间: 2008-10-27 17:53
文章分类

全部博文(14)

文章存档

2009年(6)

2008年(8)

我的朋友

分类:

2009-06-16 22:59:52

if-then-else
 

if(<boolean expression>)
{
   statements;
} else 
{
   alternative statements;
} else {

   alternative statements2;

}

单个语句的时候,花括号是可选的,但是多种语言的经验告诉我们,任何时候都使用花括号是一个良好的习惯。

switch

switch()

{

  case value0: statements;

  case value1: statements; ...

  case valueN: statements;

  default: statements;

}

TorqueScript的switch没有break语句,默认只会执行一个分支,自动break。字符串版本的switch是switch$。

switch$

switch$ ()

{

  case "string value 0": statements;

  case "string value 1": statements;

  ...

  case "string value N": statements;

  default: statements;

}

for

for(expression0; expression1; expression2)

{

statement(s);

}

while

while(expression)

{

statements;

}

阅读(467) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~