Skip to content

Instantly share code, notes, and snippets.

@toandv
Created September 13, 2015 17:16
Show Gist options
  • Save toandv/f04cf96aef7638dd84e4 to your computer and use it in GitHub Desktop.
Save toandv/f04cf96aef7638dd84e4 to your computer and use it in GitHub Desktop.
Multi-Value Hash
require 'set'
#h = Hash.new { |hash, key| hash[key] = [] }
h = Hash.new { |hash, key| hash[key] = Set.new }
h[:key] << "value 1"
h[:key] << "value 2"
h[:key2] << 1
puts h
puts h[:key].class.name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment