On Jan 1, 11:45=A0am, Joe Buck <semle2... / hotmail.com> wrote:
> Ehsan,
>
> Thanks for the help. Unfortunately I don't think that will work as it
> removes the first element in the array.
>
> What I need is an Array::delete_if or Array::reject! call that allows me
> to break from the block while still removing elements.
>
> My solution is to use a second array to keep the indices of all removed
> elements. I can then iterate through the second array after the first
> loop and remove the elements. I'm guessing reject! and delete_if do this
> as well. It could be more efficient but it works.
>
> Thanks!
> --
> Posted viahttp://www.ruby-forum.com/.

Without knowing the point of what you're trying to do, this sounds
like what you have in mind:

array =3D [] # or whatev
process_array =3D true
array.reject!(x) do
  if process_array
    conditional_code_for x
  else
    false
end