Skip to content

Instantly share code, notes, and snippets.

@andrewglind
Created May 17, 2016 21:05
Show Gist options
  • Save andrewglind/c1db20f4f2640cc2487292afc1bcfef3 to your computer and use it in GitHub Desktop.
Save andrewglind/c1db20f4f2640cc2487292afc1bcfef3 to your computer and use it in GitHub Desktop.
Use a proxy to create an anonymous method pointer
def x = ["y":{z-> println "Hello, ${z ?: 'World'}!"}].&y
x() // Hello, World!
x('Blah') // Hello, Blah!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment