# NEW UNNAMED KEYWORD ARGUMENTS def new_way(**options) return options[:foo] end # => :new_way new_way(foo: "bar") # => "bar" new_way # => nil
这里传递给new_way方法的map中,他的key必须是符号 如果传递{“ab”=>"valu"} 会报 wrong number of arguments (given 1, expected 0) (ArgumentError)
|
请发表评论