While a method with a default value profile can accept nil
(besides a hash):
def f(options = {})
options
end
f(hoge: "AAA", foo: "BBB") #=> {:hoge=>"AAA", :foo=>"BBB"}
f(nil) #=> nil
A method with double splat raises an error with nil
:
def f(**options)
options
end
f(hoge: "AAA", foo: "BBB") #=> {:hoge=>"AAA", :foo=>"BBB"}
f(nil) # => wrong number of arguments (1 for 0) (ArgumentError)
When should I use double splat and when should I use = {}
?