I think map.with_index is needed because the code is actually collecting up an array (I personally prefer collect.with_index) for this clarity and appending it to content.