From: Jeremy Woertink Date: 2007-11-08T05:15:32+09:00 Subject: Re: how to delete array 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) > > But the problem is that i dont know how much element will be populated > in my array every time the program runs and the index value will also > change. > > So i need to dynamically pass the index value and this should delete the > values pertaining to the index you could try something like... a.each_with_index do |item, index| a.delete_at(index) if item.eql?(something) end ~Jeremy -- Posted via http://www.ruby-forum.com/.