environment
- Windows
- PowerShell
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 switchesDifference 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