Skip to content

Instantly share code, notes, and snippets.

@jedediah
Created October 18, 2009 10:56
Show Gist options
  • Save jedediah/212629 to your computer and use it in GitHub Desktop.
Save jedediah/212629 to your computer and use it in GitHub Desktop.
module Enumerable
# Skip the first n elements and return
# an Enumerator for the rest, or pass them
# in succession to the block, if given.
def skip n
if block_given?
each do |x|
if n > 0
n -= 1
else
yield x
end
end
else
enum_for :skip, n
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment