# 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)
时间: 2024-12-08 00:02:21