From: Leslie Viljoen Date: 2007-11-08T05:24:17+09:00 Subject: Re: how to delete array ------=_Part_39182_13824195.1194467047371 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline On Nov 7, 2007 10:02 PM, Surjit Nameirakpam wrote: > Problem > > consider an array > > a = [1,4,6,7,9,8] > > I want to delete the array value w.r.t index > > e.g i want to delte 0,4,6 element in one go > > I can use the command > a.delete_at(0) > a.delete_at(4) > a.delete_at(6) Mostly when I have a problem like this, I find that the indexes I want to delete are a list generated by some property of the elements. ie. perhaps you want to delete indexes 0, 4, 6 because the elements at those indexes are (say) larger than three. In that case, there's a much cleaner way: a.reject!{|e| e > 3} If you can say how you calculate that list of indexes to delete, we may be able to help better. Les -- [we need your code-fu] : www.zadic.co.za ------=_Part_39182_13824195.1194467047371--