博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Ruby_day[1]控制流(if, unless)
阅读量:4320 次
发布时间:2019-06-06

本文共 626 字,大约阅读时间需要 2 分钟。

summary:

  1: if, elsif, else.注意结束if时后面加end

  2: unless, else

 

  • How to use if, else, and elsif
  • How to use comparators / relational operators like ==(相等), !=(不等), <, <=, >, and >=

How to use boolean / logical operators like &&(与), ||(或), and !(非)

1 a = 102 b = 113 if a < b4   print "a is less than b!"5 elsif b > a6   print "b is less than a!"7 else8   print "b is equal to a!"9 end

 

1 problem = false2 print "Good to go!" unless problem3 #除非有问题(problem=true时不打出来),否则打印出来

 

多个逻辑运算结合,用括号 括起来

1 ( 1 == 1 ) && ( 2 == 2 )  // true2 ( 1 == 2 ) || ( 2 == 2 ) // true3 !( false ) // true

 

 

转载于:https://www.cnblogs.com/jypwn/p/4044231.html

你可能感兴趣的文章
[Codevs] 线段树练习5
查看>>
Amazon
查看>>
component-based scene model
查看>>
Echart输出图形
查看>>
hMailServer搭建简单邮件系统
查看>>
从零开始学习jQuery
查看>>
Spring+SpringMVC+MyBatis深入学习及搭建(四)——MyBatis输入映射与输出映射
查看>>
opacity半透明兼容ie8。。。。ie8半透明
查看>>
CDOJ_24 八球胜负
查看>>
Alpha 冲刺 (7/10)
查看>>
一款jQuery打造的具有多功能切换的幻灯片特效
查看>>
SNMP从入门到开发:进阶篇
查看>>
@ServletComponentScan ,@ComponentScan,@Configuration 解析
查看>>
unity3d 射弹基础案例代码分析
查看>>
thinksns 分页数据
查看>>
os模块
查看>>
LINQ to SQL vs. NHibernate
查看>>
基于Angular5和WebAPI的增删改查(一)
查看>>
windows 10 & Office 2016 安装
查看>>
最短路径(SP)问题相关算法与模板
查看>>