[Ruby笔记]2. ruby基础的基础: irb --simple-prompt / puts print p/ false nil
2016-05-16 02:09
423 查看
irb –simple-prompt
PS C:\Users\Administrator> irb irb(main):001:0> exit() PS C:\Users\Administrator> irb --simple-prompt >> exit() PS C:\Users\Administrator>
simple模式更“清爽”
puts print p
创建两个变量x、yPS C:\Users\Administrator> irb --simple-prompt >> x = "hello" => "hello" >> y = "world" => "world"
p 无视了转义符号
puts 输出自带换行,print给啥写啥不带换行
>> p x + " \n " + y "hello \n world" => "hello \n world" >> print x + " \n " + y hello world=> nil #注意:这里没有换行就输出了nil >> puts x + " \n " + y hello world => nil #注意:这里换行后再输出了nil
false nil
Ruby中 除了 [b]false 以及 nil[/b] 其余在条件判断中都是true的作用0 (Zero零)在ruby中也是true
PS C:\Users\Administrator\RubyCode> ls 目录: C:\Users\Administrator\RubyCode Mode LastWriteTime Length Name ---- ------------- ------ ---- -a--- 2016/5/16 2:00 48 ex111.rb PS C:\Users\Administrator\RubyCode> more ex111.rb if 0 puts "true" elsif puts "false" end PS C:\Users\Administrator\RubyCode> ruby ex111.rb true
Reference
> 《The Well-Grounded Rubyist, Second Edition》 (https://www.manning.com/books/the-well-grounded-rubyist-second-edition) 1.1.1. A Ruby syntax survival kit > /ヽ /ヽ / ヽ / ヽ / ヽ__/ ヽ / \ / \ / | | ● ● | |. (__人__) | ヽ / / \ /  ̄ ̄ヽ / ̄ ヽ ヽ_______/ \__/ [[二二二二二二二二二二二二二二二二 http://kaomojiya.com/ascii/4page.php[/code]
相关文章推荐
- 红宝石(Ruby)史话
- Ruby简明教程之循环语句介绍
- ruby 一些简单的例子
- Ruby on Rails在Ping ++ 平台实现支付
- Ruby 之 class 中的 private、 protected、public
- Ruby中操作文件的方法介绍
- Ruby中的集合编写指南
- CentOS 6.3下编译安装Ruby 2.0笔记
- Ruby基本的环境变量设置以及常用解释器命令介绍
- Ruby编程中关于中断和返回的用法教程
- Ruby中的异常处理代码编写示例
- Ruby程序中发送基于HTTP协议的请求的简单示例
- Ruby中的变量学习总结
- 几个加速Ruby on Rails的编程技巧
- Ruby配置rspec和RestClient来检测服务器
- 分析Cache 在 Ruby China 里面的应用情况
- Ruby中数组的一些相关使用方法
- 编写Ruby代码注释时需要注意的一些问题
- Ruby类继承、抽象类、类拓展混入、代理类实例