标签:style blog color io ar java sp div on
summary:
1: if, elsif, else.注意结束if时后面加end
2: unless, else
if
, else
, and elsif
==(相等)
, !=(不等)
, <
, <=
, >
, and >=
How to use boolean / logical operators like &&(与)
, ||(或)
, and !(非)
1 a = 10 2 b = 11 3 if a < b 4 print "a is less than b!" 5 elsif b > a 6 print "b is less than a!" 7 else 8 print "b is equal to a!" 9 end
1 problem = false 2 print "Good to go!" unless problem 3 #除非有问题(problem=true时不打出来),否则打印出来
多个逻辑运算结合,用括号 括起来
1 ( 1 == 1 ) && ( 2 == 2 ) // true 2 ( 1 == 2 ) || ( 2 == 2 ) // true 3 !( false ) // true
标签:style blog color io ar java sp div on
原文地址:http://www.cnblogs.com/jypwn/p/4044231.html