I have an array:
array = [1,2,3,4,5,2,6,7,2,8,9,2,10]
I want to replace all the 2s with 'x' and can't do this. I tried:
- 1st attempt:
array.select{|num| num == 2? num = 'x' : num} - 2nd attempt:
array.select{|num| num == 2}.replace(['x'])
I'm making this harder than it is.