Skip to content

Instantly share code, notes, and snippets.

@softprops
Created July 4, 2009 16:36
Show Gist options
  • Save softprops/140624 to your computer and use it in GitHub Desktop.
Save softprops/140624 to your computer and use it in GitHub Desktop.
Array.class_eval {
# [1,2,3,4].each_with_previous do |el, prev|
# p "el:#{el}, prev:#{prev}"
# end
#
def each_with_previous
prev = nil
each do |el|
yield(el, prev)
prev = el
end
end
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment