To find a shorter way to convert an array into a hash with indices as values, you can use the with_index
method. Here's the updated code:
main.rb100 chars3 lines
This code is more concise as it combines the map
and with_index
methods to directly convert the array into a hash with indices as values.
gistlibby LogSnag