It looks like groovysh
stores:
def a(n) { n*n }
as a MethodClosure into a binding variable called a
This will not happen outside of groovysh, and as you have seen you'll need to define a as a closure:
def a = { n -> n*n }
def x( m ) { m( 2 ) }
x(a)
Or use the method reference operator &
:
def a(n) { n*n }
def x(m) { m(2) }
x( this.&a )