0
我在ruby中遇到了可选参数的weirb问题。 这是我的代码:设置可选参数将其他参数的默认值设置为零
def foo options={:test => true}
puts options[:test]
end
foo # => puts true
foo :lol => 42 # => puts nil
我想不通,为什么第二个电话把零。 似乎是把其他参数设置为:测试为零。
谢谢。
相关:https://github.com/bbatsov/ruby-style-guide/issues/63 – tokland