Created
June 11, 2014 17:27
-
-
Save uri/49508c3bbb21c6b437bd to your computer and use it in GitHub Desktop.
Uri's Mini hack challenge: 1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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