Ruby 为什么 caller 方法在脚本中不返回任何东西呢?

ailms · September 28, 2012 · Last by ailms replied at September 29, 2012 · 2363 hits

你想 puts 出 caller 的方法堆栈么?那为什么不用 puts

不是,而是上面的代码在 irb 下是可以输出 call stack 的。但为什么放到脚本里面就不行呢?

irb 会自动输出返回值的 inspect 到 stdout。脚本里你要自己 puts

You need to Sign in before reply, if you don't have an account, please Sign up first.