The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

fiallega (9) [Avatar] Offline
On page 165 sec 5.5.2 says
Therefore, the Groovy team has decided that inside a closure this doesn't refer to the closure object but to its owner: the object in whose scope the closure was declared.

then: how can I refer to the closure object, within the closure object ?
Mittie (397) [Avatar] Offline
Re: this inside closure
Hi Jorge,

there are a few use cases when you ever want to do that, e.g. when a closure wants to call itself for recursive algorithm. In this case you need a reference to the closure from the enclosing scope like so:

def cl
cl = { println cl }

// calling it