« Return to Thread: Expando methods: how to get hold of the object a method is called on

Expando methods: how to get hold of the object a method is called on

by Steven Devijver :: Rate this Message:

Reply to Author | View in Thread

Consider this Expando method:

def stringMetaClass = new ExpandoMetaClass(String.class, true)

stringMetaClass.aMethod << { it.toUpperCase() }

stringMetaClass.initialize()

However, when I call the method "it" is null:

"test".aMethod()

How to get hold in a closure of the object where an Expando method is called on?

Thanks

Steven

---------------------------------------------------------------------
To unsubscribe from this list please visit:

    http://xircles.codehaus.org/manage_email

 « Return to Thread: Expando methods: how to get hold of the object a method is called on