Module: Footing::NilClass

Defined in:
lib/footing/extensions/nil_class.rb

Instance Method Summary collapse

Instance Method Details

#[](key) ⇒ Object

Calling [] on nil returns nil instead of raising an exception. Helpful when looping over nested Hashes.

Examples:

dict = {}
dict[:foo][:bar][:baz] # => nil

Parameters:

  • key (Object)

    The key to lookup.



12
13
14
# File 'lib/footing/extensions/nil_class.rb', line 12

def [](key)
  nil
end