Project

General

Profile

Actions

Bug #11776

closed

dig and custom objects

Added by marcandre (Marc-Andre Lafortune) over 8 years ago. Updated over 6 years ago.

Status:
Closed
Target version:
-
ruby -v:
2.3.0 preview
[ruby-core:71853]

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

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0