Replacing num.times.map with Array.new(num)
I want to create an array containing objects created with an incrementing integer index parameter. For example, an array of hashes containing strings built off of the incrementing number.
my_array = num.times.map do |index| build_hash(index) end
BUT...rubocop didn't like this:
... C: Performance/TimesMap: Use Array.new with a block instead of .times.map
The improved solution allows us to build the same array with less chained methods, thus improving readability:
my_array = Array.new(num) do |index| build_hash(index) end