Ruby display each array item's index
my_vitamins.each_with_index do |vitamin, index|
puts "#{index} cheers for #{vitamin}!"
end
=> 0 cheers for b-12!
=> 1 cheers for c!
=> 2 cheers for riboflavin!
Sat, 20 Feb 2010 18:18 Posted in Ruby/Rails
1 comment »
-
By TJ Moretto 13 days later:
Dork.