Skip to content

Instantly share code, notes, and snippets.

Created May 25, 2012 15:33
Show Gist options
  • Save anonymous/2788808 to your computer and use it in GitHub Desktop.
Save anonymous/2788808 to your computer and use it in GitHub Desktop.
Iterator slice
letters = %w(a b c d e f g h i j)
# iterator args: offset, length
letters.some_kind_of_iterator(3, 5) do |letter, index|
puts "#{index} - #{letter}
end
## Desired output:
'3 - d'
'4 - e'
'5 - f'
'6 - g'
'7 - h'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment