Actions
Bug #11776
closeddig and custom objects
Description
Although currently undocumented and untested, it is possible to dig
objects of any class that implements dig
:
class Foo
def dig(x, *)
40 + x
end
end
{hello: Foo.new}.dig(:hello, 2) # => 42
This seems actually quite nice to me.
Matz, could you confirm that this is part of the new feature? I'll fix the documentation and add some basic tests
Updated by Eregon (Benoit Daloze) over 8 years ago
There is already a spec for this behavior though :)
https://github.com/ruby/rubyspec/blob/master/core/hash/dig_spec.rb
Updated by matz (Yukihiro Matsumoto) over 8 years ago
Confirmed. ;-)
Matz.
Updated by marcandre (Marc-Andre Lafortune) over 6 years ago
- Status changed from Open to Closed
Actions
Like0
Like0Like0Like0