[Ruby笔记]10. Ruby object return Boolean nil false #{}
来源:互联网 发布:2017淘宝双十一攻略 编辑:程序博客网 时间:2024/06/05 02:53
Ruby中一切皆对象,任何对象都有一个布尔值返回值(Boolean value)
nil
puts "Hello world"
这个语句返回Boolean
值nil
,并且按照功能输出字符串Hello world
;
PS C:\Users\Administrator\RubyCode> irb --simple-prompt>> puts "Hello world"Hello world=> nil>> if puts "Hello world">> puts "You can't see this">> endHello world=> nil
false or true
1 == 2
返回Boolean
值false
;if...end
代码块整体返回Boolean
值nil
;
PS C:\Users\Administrator\RubyCode> irb --simple-prompt>> if 1 == 2>> puts " One is equal to Two">> end=> nil>> 1 == 2=> false>> 1 != 2=> true
extra #{}
#{} 里面使用占位符输出浮点数值如下(还自动给四舍五入了):
PS C:\Users\Administrator\RubyCode> more ex2.rb# string outputh_w = 'hello world'puts "This is #{h_w}"# number outputfloat_num = 1.230567puts "#{"num is %.3f" %float_num}"PS C:\Users\Administrator\RubyCode> ruby ex2.rbThis is hello worldnum is 1.231
reference
《The Well-Grounded Rubyist, Second Edition》
(https://www.manning.com/books/the-well-grounded-rubyist-second-edition)
2.2. Crafting an object: The behavior of a ticket
どんだけ~ η゛ ∧ ∧(≡) (´∀`) /⊂ ノ (つ ノ (ノhttp://emoji.vis.ne.jp/dondake.htm
0 0
- [Ruby笔记]10. Ruby object return Boolean nil false #{}
- [Ruby笔记]2. ruby基础的基础: irb --simple-prompt / puts print p/ false nil
- Ruby中的关键字nil
- [Ruby笔记]13.Ruby object .replace("") .dup .freeze
- [Ruby]ruby笔记01
- [Ruby]ruby笔记02
- Ruby Range in Boolean expressions
- how to sort array in ruby if i have nil object inside array?
- ruby笔记
- ruby笔记
- ruby笔记
- ruby笔记
- Ruby笔记
- Ruby 笔记
- 【ruby学习笔记】初探ruby
- [Ruby笔记]14.Ruby local_variable
- [Ruby]Guide to return statement
- [Ruby笔记]1. ruby ruby oh~ ruby 安装
- [Ruby笔记]7.ruby -e ' " 单引号、双引号对比
- OpenGL纹理贴图
- 地铁译:Spark for python developers ---构建Spark批处理和流处理应用前的数据准备
- [Ruby笔记]8. Ruby Rakefile rake 删除文件 确认
- 【Java】Java内存参数配置
- [Ruby笔记]10. Ruby object return Boolean nil false #{}
- 身份证的奥秘问题(待修改)
- [Ruby笔记]11.Ruby == .equal? object .object_id .respond_to? .send()
- FPGA:下一代机器人感知处理器
- AT5 two-dimensional objects - the torus and genus
- cobar初识记录(mysql)
- [Ruby笔记]9.Ruby文档工具 ri ruby-doc Windows CMD.exe Powershell
- 哈夫曼树及其应用
- java学习总结(16.05.17)对数据类型取值范围和数据溢出的理解(以byte类型为例)