rubyでeach_with_indexみたいなことをmapでもやりたい
with_indexをmapにつなげて書けばよいようだ
array = ['apple', 'peach', 'orange'] p array.map.with_index{|v, index| index > 1 ? 'hoge' : v} => ["apple", "peach", "hoge"]
with_indexをmapにつなげて書けばよいようだ
array = ['apple', 'peach', 'orange'] p array.map.with_index{|v, index| index > 1 ? 'hoge' : v} => ["apple", "peach", "hoge"]