Skip to content

Instantly share code, notes, and snippets.

@ysinc88
Last active December 28, 2017 20:27
Show Gist options
  • Save ysinc88/0d6951ee3f4f6aa004dd1c0467b8e626 to your computer and use it in GitHub Desktop.
Save ysinc88/0d6951ee3f4f6aa004dd1c0467b8e626 to your computer and use it in GitHub Desktop.
Hashes of numbers, used to populate collections
range_array = *(1..20)
@nums = range_array.map{|n| Hash[n, n] }.reduce({}, :merge)
#=> {1=>1, 2=>2, 3=>3, 4=>4, 5=>5, 6=>6, 7=>7, 8=>8, 9=>9, 10=>10, 11=>11, 12=>12, 13=>13, 14=>14, 15=>15, 16=>16, 17=>17, 18=>18, 19=>19, 20=>20}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment