# code.rb
def hello
puts "hello"
end
:$ ruby code.rb
控制台上没有输出!我使用Ubuntu 13.04。为什么在控制台上禁止Ruby输出?
如果我在IRB中运行相同的代码,它的工作原理!
# code.rb
def hello
puts "hello"
end
:$ ruby code.rb
控制台上没有输出!我使用Ubuntu 13.04。为什么在控制台上禁止Ruby输出?
如果我在IRB中运行相同的代码,它的工作原理!
你要打电话给你的代码,你只是定义一个方法:
# code.rb
def hello
puts "hello"
end
hello
$ ruby code.rb
您需要调用的方法,在这种情况下,hello
脚本:
def hello
puts "hello"
end
hello
你定义一个方法,但你永远不会调用它。试试这个:
# code.rb
def hello
puts "hello"
end
hello
运行:
:$ ruby code.rb
什么在这种情况下,IRB输出? –