On May 15, 2006, at 7:48 PM, Susan Sash wrote: > Is there a way to iterate through an array, getting the index and the > object at the same time? $ri each_with_index --------------------------------------------- Enumerable#each_with_index enum.each_with_index {|obj, i| block } -> enum ------------------------------------------------------------------------ Calls block with two arguments, the item and its index, for each item in enum. hash = Hash.new %w(cat dog wombat).each_with_index {|item, index| hash[item] = index } hash #=> {"cat"=>0, "wombat"=>2, "dog"=>1} -- Daniel