Issue #22012 has been updated by zverok (Victor Shepelev). This was a conscious design decision on Data implementaion, that underlines its nature. Struct has a two-fold nature: it is both "a mutable structured object" and "a container" (has `#[]`, `#each`, includes `Enumerable`). Data is a base for composite value objects; so in designing it, the focus was on other composite value objects in Ruby, like Time. We don't have `Time.now.dig(:year)` and things like that, making a distinction between "navigable containers" and "atomic value objects". If `Data`-based class used in some context as a base of a container-like object, the implementation of `#dig` is relatively trivial: ```ruby class Locations < Data.define(:work, :home, :shelter) def dig(first, *rest) return unless members.include?(first) send(first).then { rest.empty? ? it : it.dig(*rest) } end end ``` ---------------------------------------- Feature #22012: Data class should respond to #dig https://bugs.ruby-lang.org/issues/22012#change-117095 * Author: kolbrich (Kevin Olbrich) * Status: Open ---------------------------------------- `Data`s cousin, `Struct` already responds to `#dig`. `Data` objects can show up in deeply nested objects as well, and the semantics of this should be nearly identical to `Struct#dig` -- https://bugs.ruby-lang.org/