Advertisement
saasbook

each_with_index.rb

Aug 15th, 2013
325
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
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement