Class: Hashish

Inherits:
Object show all
Defined in:
lib/babushka/core_patches/hashish.rb

Class Method Summary collapse

Class Method Details

.arrayObject

Return a new hash whose default value is an empty array; i.e. querying any un-assigned key will assign and return an empty array to that key.



4
5
6
# File 'lib/babushka/core_patches/hashish.rb', line 4

def self.array
  Hash.new {|hsh,k| hsh[k] = [] }
end

.hashObject

Return a new hash whose default value is an empty hash; i.e. querying any un-assigned key will assign and return an empty hash to that key. Note that the empty hash is a regular hash and doesn’t have any default keys of its own.



11
12
13
# File 'lib/babushka/core_patches/hashish.rb', line 11

def self.hash
  Hash.new {|hsh,k| hsh[k] = {} }
end