From: James Gray Date: 2009-07-02T21:51:28+09:00 Subject: Re: delete_if_with_index or delete_at(array) in 1.8.6? On Jul 2, 2009, at 7:20 AM, Bil Kleb wrote: > Given an array of integers, I need to delete all those > entries that are lower than the current array index. > Anything more elegant available? > > Or perhaps an alternative way to attack the problem? On Ruby 1.9, your very first example can almost be made to work as is: >> a = Array.new(10) { |i| i + [-1, 0, 1][rand(3)] } => [-1, 1, 2, 4, 3, 5, 7, 7, 9, 10] >> a.delete_if.with_index { |e, i| e < i } => [1, 2, 4, 5, 7, 7, 9, 10] James Edward Gray II