Method Closures Problem

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Method Closures Problem


I'm implementing grails interceptors at the moment and I was planning
on promoting the method pointer/closure syntax as a way of making
certain actions 'private' ie not exposed as web actions like so:

class TestController {
        @Property beforeInterceptor = [action:&before,only:list]
        // private because its a method not a closure property
        def before() {
            // interceptor code goes here
        // an intercepted action
        @Property list = {


However its failing to compile on the the line:
        @Property beforeInterceptor = [action:&before,only:list]

with the message:
startup failed, script1142877811828.groovy: 2: unexpected token: & @
line 2, column 39.
1 Error

If i change this to with an explicit 'this' all works fine:
        @Property beforeInterceptor = [action:this.&before,only:list]

So my question is is it not possible to reference methods in this way
without the 'this'?