Special code for this example. Perhaps this will not work on your other arrays. Instead of actually moving the element, let's split the old array and build two new arrays.
x = ['a', 'b', 'c'] x, y = x.partition {|i| i != 'b'} x # => ["a", "c"] y # => ["b"]
The delete_at approach is probably better for your situation, but you know it's good to know the alternatives :)
source share