Ruby Array Ersetzen Sie Element
p array.map { |x| x == 4 ? 'Z' : x }
# => [1, 2, 3, 'Z']
Fancy Ferret
p array.map { |x| x == 4 ? 'Z' : x }
# => [1, 2, 3, 'Z']