On 25 f=E9vr. 2010, at 19:20, David Springer wrote: > textlist =3D ["Apple", "Orange", "Lemon", "Grape", "Orange",=20 > "Melon","Orange", "Banana"] >=20 > i =3D textlist.index("Orange") >=20 > if !i.nil? > puts "textlist[" << i.to_s << "] is \"" << textlist[i] << "\"" > j =3D textlist[i+1,textlist.length-i-1].index("Orange")+i+1 > if !j.nil? > puts "textlist[" << j.to_s << "] is \"" << textlist[j] << = "\"" > end > end class Array def indexes_of(obj) indexes =3D Array.new self.each_with_index {|s,i| indexes << i if s =3D=3D=3D obj } return indexes end end textlist =3D ["Apple", "Orange", "Lemon", "Grape", "Orange", = "Melon","Orange", "Banana"] p textlist.indexes_of("Orange") #=3D> [1,4,6] --=20 Luc Heinrich - luc / honk-honk.com