a = [1,2,3,4,5,6,7,8,9,10] a = a.map do |i| #next if i.even? next i if i.even? i*10 end p a #=>[10, nil, 30, nil, 50, nil, 70, nil, 90, nil] #=>[10, 2, 30, 4, 50, 6, 70, 8, 90, 10] Register as a new user and use Qiita more conveniently You get articles that match your needsYou can efficiently read back useful informationYou can use dark themeWhat you can do with signing up