Skip to content

Instantly share code, notes, and snippets.

@uri
Created June 11, 2014 17:27
Show Gist options
  • Save uri/49508c3bbb21c6b437bd to your computer and use it in GitHub Desktop.
Save uri/49508c3bbb21c6b437bd to your computer and use it in GitHub Desktop.
Uri's Mini hack challenge: 1
# Take an array [221,222,223,224] and turn it into {221 => 1, 222 => 1, 223 => 1, 224 => 1}
start = [221,222,223,224]
# My almost illegible implementation
result = Hash[*start.map(&:id).zip([1] * start.count)]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment