unless
#unless = if not
#每次头脑发昏的时候,都需要将unless转换成如上所示
arr = ["one", "two", "three"]
#示例
unless arr.empty?
arr.each do |i|
p i
end
end
#常用法,如果语句短的话,条件判断是放在语句的最后面
arr.each { |i| p i} unless arr.empty?
elsif
#当出现三个或者三个以上的判断语句的时候使用
if conditions
xx
elsif conditions
xx
else conditions
xx
end
compound condition
&& and
|| or
!
== 和 !=
几个判断的优先级比较