Skip to content

Instantly share code, notes, and snippets.

@hrstt
Created August 30, 2011 08:05
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 hrstt/1180431 to your computer and use it in GitHub Desktop.
Save hrstt/1180431 to your computer and use it in GitHub Desktop.
Ruby: Hash初期化でブロックを利用.各要素に空配列を用意する
hash = Hash.new{|h,k| h[k] = []}
hash[:test] << "Hello" #=> {:test => ["Hello"]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment