I have an array and a hash
L = []
H = {3=>"a", 2=>"b", 1=>"c"}
And so I will iterate over the keys to get the number of times n the element occurs and append that element to an array n times
Result
L = ['a', 'a', 'a', 'b', 'b', 'c']
What’s a nice way to write this with inject (or other methods that I often see in ruby code)?
1 Answer