# code.rb
def hello
puts "hello"
end
:$ ruby code.rb
Run Code Online (Sandbox Code Playgroud)
控制台上没有输出任何内容!我正在使用Ubuntu 13.04.
如果我在IRB中运行相同的代码,它的工作原理!
你必须调用你的代码,你只需要定义一个方法:
# code.rb
def hello
puts "hello"
end
hello
$ ruby code.rb
Run Code Online (Sandbox Code Playgroud)