Skip to content

Instantly share code, notes, and snippets.

@pasberth
Created July 17, 2011 07:52
Show Gist options
  • Save pasberth/1087333 to your computer and use it in GitHub Desktop.
Save pasberth/1087333 to your computer and use it in GitHub Desktop.
# ary = [0, 1, 2, 3]
# ary.shift.foo until ary.empty?
#
# is equal to:
#
# ary = [0, 1, 2, 3]
# ary.featch { |e| e.foo }
class Array
# naming of 'fetch each' => featch
def featch
yield shift until empty?
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment