On Apr 24, 10:04=A0am, Frisco Del Rosario <fri... / appleisp.netNO> wrote:
> myArray =3D [1, 2, 3]
>
> puts myArray
>
> myArray.each {|x| =A0
> if x =3D=3D 1
> =A0 then puts "one"
> =A0 elsif x =3D=3D 2
> =A0 =A0 then
> =A0 =A0 myArray.delete x
> =A0 elsif x =3D=3D 3
> =A0 =A0 then puts "three"
> =A0 end =A0
> =A0 }
>
> puts myArray
>
> The output of the above is:
> 1
> 2
> 3
> one
> 1
> 3
>
> And my question is "why isn't it 1 2 3 one three 1 3?". What if I wanted
> to make it so?

I just dup, like this:
myArray.dup.each {|x| ... delete from (original) myArray in
here .... }

I'm sure there are more elegant solutions, and it's a bit pants from a
performance perspective for large arrays, but it works for me.