Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUBY

ruby array replace element

p array.map { |x| x == 4 ? 'Z' : x }

# => [1, 2, 3, 'Z']
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #ruby #array #replace #element
ADD COMMENT
Topic
Name
3+8 =