[Ruby笔记]7.ruby -e ' " 单引号、双引号对比
2016-05-20 03:16
501 查看
environment
WindowsPowerShell
ruby -e
使用ruby -e "..."可以在命令行直接运行脚本
PS C:\Users\Administrator\RubyCode> ruby -e "print 'Enter a name: '; print gets.reverse" Enter a name: Tom moT
’ vs “
自己机器,在powershell里结合
-e选项,使用单引号遭遇错误:
PS C:\Users\Administrator> ruby -e 'puts "hell world"' -e:1:in `<main>': undefined local variable or method `hell' for main:Object (NameError)
-e后面使用双引号
”框起来就没有问题了:
PS C:\Users\Administrator> ruby -e "puts 'hell world' " hell world
单双引号的具体区别如下:
C:\Users\Administrator\RubyCode> irb irb(main):001:0> puts "Hi #{1+1}" Hi 2 => nil irb(main):002:0> puts 'Hi #{1+1}' Hi #{1+1} => nil irb(main):003:0>
reference
《The Well-Grounded Rubyist, Second Edition》(https://www.manning.com/books/the-well-grounded-rubyist-second-edition)
1.4.1. Interpreter command-line switches
Difference betweem double quotation marks ” and single quotation mark ’ in Ruby [duplicate]
http://stackoverflow.com/questions/25557052/difference-betweem-double-quotation-marks-and-single-quotation-mark-in-ruby
-= ∧_∧ エ -=≡(;´(エ)`)ラ -= (つ┳つ イ -=≡ / ┃/ コ -=≡ / / ┃) ッ ◎━\)┻◎ チ  ̄ミ ̄ ̄ ̄キ ̄ ャ http://emoji.vis.ne.jp/kickboard.htm[/code]
相关文章推荐
- 如何重装TCP/IP协议
- Windows 8 官方高清壁纸欣赏与下载
- 谁是桌面王者?Win PK Linux三大镇山之宝
- 对《大家都在点赞 Windows Terminal,我决定给你泼一盆冷水》一文的商榷
- Windows Clang开发环境备忘
- 从Windows系统下访问Linux分区相关软件
- 对《大家都在点赞 Windows Terminal,我决定给你泼一盆冷水》一文的商榷
- Windows下搭建本地SVN服务器
- 使用Windows原生命令一键清空剪贴板
- 红宝石(Ruby)史话
- 利用开源软件打造自己的全功能远程工具
- Windows 8虚拟机不能全屏的解决方法
- Visual Studio 2012 示例代码浏览器 - 数以千计的开发示例近在手边,唾手可得
- Visual Studio 2012 示例代码浏览器 - 数以千计的开发示例近在手边,唾手可得
- 微软镜像下载
- windows server域用户提升到本地更高权限组中的方法