saasbook

each_with_index_1.rb

May 1st, 2012
349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.19 KB | None | 0 0
  1. include Enumerable
  2. %w(alice bob carol).each_with_custom_index(3,2) do |person,index|
  3.   puts ">> #{person} is number #{index}"
  4. end
  5. >> alice is number 3
  6. >> bob is number 5
  7. >> carol is number 7
Advertisement
Add Comment
Please, Sign In to add comment