Actions
Bug #17595
closed[Pattern Matching] deconstruct_keys with zero patterns supplies nil for keys argument
Description
Example:
Test = Struct.new(:a, :b) do
def deconstruct_keys(ks)
p ks: ks
to_h.slice(*ks)
end
end
# => Test
Test.new(1,2) in {}
# {:ks=>nil}
# => true
As users may call Array
methods against the keys
argument I consider this a potential bug that it returns nil
for no supplied arguments.
Proposed Patch: Pass an empty array instead to maintain interface consistency.
Actions
Like0
Like0Like0