Skip to content

Instantly share code, notes, and snippets.

@mrzasa
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrzasa/624135e254d4c981f01f to your computer and use it in GitHub Desktop.
Save mrzasa/624135e254d4c981f01f to your computer and use it in GitHub Desktop.
Hash default and symbolize
h = {}
h[:a]
h.default = 0
h[:a] += 1
h = Hash.new(0)
require 'active_support/core_ext/hash/indifferent_access'
h = {"a" => 1, "b" => 2}
h.symbolize_keys
h.with_indifferent_access[:a]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment