Created
August 20, 2009 00:48
-
-
Save rhysyngsun/170746 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Example #1 | |
def splitMe = 'First sentence. Second.' | |
def cl = { split('.') } | |
cl.resolveStrategy = Closure.DELEGATE_FIRST | |
cl.delegate = splitMe | |
def sentences = cl() | |
// Example #2 (shorthand for #1) | |
def splitMe = 'First sentence. Second.' | |
def cl = { split('.') } | |
def sentences = splitMe.with(cl) | |
// Example #3 (the infamous it) | |
def splitMe = 'First sentence. Second.' | |
def cl = { it.split('.') } | |
def sentences = cl.call(splitMe) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment