module Dig

Overview

Object#dig and Object#dig? methods are used to returns deeply nested values. Ideas taken from: https://www.reddit.com/r/crystal_programming/comments/477bnn/crystal_on_steroids/d0c07lt

Direct including types

Defined in:

crystal_on_steroids/dig.cr

Instance Method Summary

Instance Method Detail

def dig(index) #

[View source]
def dig(index, *keys) #

Retrieves the value object corresponding to the each key objects repeatedly.

h = { foo: {bar: {baz: 5}}}

h.dig(:foo, :bar, :baz)           #=> 5
h.dig(:foo, :blah)                #=> nil

[View source]