saasbook

each_with_index.rb

Mar 13th, 2014
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.16 KB | None | 0 0
  1. %w(alice bob carol).each_with_index do |person,index|
  2.   puts ">> #{person} is number #{index}"
  3. end
  4. >> alice is number 0
  5. >> bob is number 1
  6. >> carol is number 2
Add Comment
Please, Sign In to add comment