Skip to content

Instantly share code, notes, and snippets.

@gavinheavyside
Last active January 4, 2016 16:39
Show Gist options
  • Save gavinheavyside/8648980 to your computer and use it in GitHub Desktop.
Save gavinheavyside/8648980 to your computer and use it in GitHub Desktop.
Hash[] difference between Ruby 1.9 and 2.x
# Ruby 1.9:
Hash[ [ "", "key:value" ].map { |v| v.split( /:/) } ]
# => {"key"=>"value"}
# Ruby 2.0+:
Hash[ [ "", "key:value" ].map { |v| v.split( /:/) } ]
# ArgumentError: invalid number of elements (0 for 1..2)
# from (pry):1:in `[]'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment