How to run the ruby code

The first, ruby ​​-e

Run the following command at the command line, -e mean, the back of the string as script execution

ruby -e "print 'hello'"

Use irb interactive console

At the command line, type irb

hello worldxingoo@xingoo-Lenovo:~/workspace/RubyTest$ irb
irb(main):001:0> p "hello"
"hello"
=> "hello"
irb(main):002:0> p "中文hello"
"中文hello"
=> "中文hello"
irb(main):003:0> eixt

Execute commands using ruby

xingoo@xingoo-Lenovo:~/workspace/RubyTest/KittyRuby$ ruby hello.rb 
hello world

hello.rb contents:

print "hello world"

Reproduced in: https: //my.oschina.net/u/204616/blog/545067

Guess you like

Origin blog.csdn.net/weixin_34149796/article/details/91989614