Autovivification - Ruby

Ruby

Ruby hashes can take a block specifying an object to be returned for non-existing indexes. These can be used to implement autovivificious maps.

tree = proc { Hash.new { |hash, key| hash = tree.call } } lupin = tree.call lupin = "stand and deliver"

Read more about this topic:  Autovivification

Famous quotes containing the word ruby:

    A man in the house is worth two in the street.
    Mae West, U.S. actor, screenwriter, and Leo McCarey. Ruby Carter (Mae West)

    Its quick silver bell beating, beating
    And down the dark one ruby flare
    Pulsing out red light like an artery,
    Karl Shapiro (b. 1913)

    It is better to be looked over than overlooked.
    Mae West, U.S. actor, screenwriter, and Leo McCarey. Ruby Carter (Mae West)