add nil#to_h; ref #2348

parent e52533a7
...@@ -691,4 +691,8 @@ module Enumerable ...@@ -691,4 +691,8 @@ module Enumerable
end end
h h
end end
def nil.to_h
{}
end
end end
...@@ -157,4 +157,6 @@ assert("Enumerable#to_h") do ...@@ -157,4 +157,6 @@ assert("Enumerable#to_h") do
h = c.new.to_h h = c.new.to_h
assert_equal Hash, h.class assert_equal Hash, h.class
assert_equal h0, h assert_equal h0, h
# mruby-enum-ext also provides nil.to_h
assert_equal Hash.new, nil.to_h
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment