Sha256: 7fca54293331f3db4cc9a9bc582ee162274dbd2ad8b656f76ca42edb676bbe65

Contents?: true

Size: 333 Bytes

Versions: 9

Compression:

Stored size: 333 Bytes

Contents

#!/usr/bin/env ruby
# -*- encoding: utf-8 -*-
# Copyright muflax <mail@muflax.com>, 2013
# License: GNU GPL 3 <http://www.gnu.org/copyleft/gpl.html>

# simple auto-vivifying hash
# TODO support nested hashes
def vivaHash default=[]
  hash = Hash.new do |h, k|
    h[k] = default.duplicable? ? default.dup : default
  end

  hash
end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
muflax-0.2.6 lib/muflax/hash.rb
muflax-0.2.5 lib/muflax/hash.rb
muflax-0.2.4 lib/muflax/hash.rb
muflax-0.2.3 lib/muflax/hash.rb
muflax-0.2.2 lib/muflax/hash.rb
muflax-0.2.1 lib/muflax/hash.rb
muflax-0.2.0 lib/muflax/hash.rb
muflax-0.1.35 lib/muflax/hash.rb
muflax-0.1.34 lib/muflax/hash.rb