Skip to content

Instantly share code, notes, and snippets.

@kristjan
Created June 7, 2015 19:07
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 kristjan/87be1352953490e4b9b5 to your computer and use it in GitHub Desktop.
Save kristjan/87be1352953490e4b9b5 to your computer and use it in GitHub Desktop.
Demo bug using Array#product to build a hash
tags = %w[tag1 tag2 tag3]
h = tags.product([[]]).to_h
#=> {"tag1"=>[], "tag2"=>[], "tag3"=>[]}
h['tag1'] << 1
#=> [1]
h
#=> {"tag1"=>[1], "tag2"=>[1], "tag3"=>[1]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment