What is happening below seems a little strange to me.
def f(a, b)
puts "#{a} :: #{b}"
end
f(*[1, 2], **{}) # prints "1 :: 2"
hash = {}
f(*[1, 2], **hash)
ArgumentError: wrong number of arguments (3 for 2)
f(*[1, 2], **Hash.new)
ArgumentError: wrong number of arguments (3 for 2)
Is this a compiler optimization feature?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…