分类: Python/Ruby
2012-10-08 10:55:37
一个简单的例子:
if {$vbl == 1} { puts "vbl is one" }带有一个else子句:
if {$vbl == 1} { puts "vbl is one"} else { puts "vbl is not one"}带有一个elseif子句:
if {$vbl == 1} { puts "vbl is one"} elseif {$vbl == 2} { puts "vbl is two"} else { puts "vbl is not one or two"}表达式可以是多行的,但是在这种情况下就需要使用then关键字是结构清晰。
if { $vbl == 1 || $vbl == 2 || $vbl == 3} then { puts "vbl is one, two or three"}