Skip to content

Instantly share code, notes, and snippets.

@rhzs
Last active August 29, 2015 14:21
Show Gist options
  • Save rhzs/ecababd669caa3327451 to your computer and use it in GitHub Desktop.
Save rhzs/ecababd669caa3327451 to your computer and use it in GitHub Desktop.
Collection.metaClass.eachWithPeek = { closure ->
def last = null
delegate?.each { current ->
if (last) closure(last, current)
last = current
}
if (last) closure(last, null)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment