Groovy -- What is the difference between this and owner -
according this this
, owner
seem have same meaning. reading further find owner
can refer enclosing class or closure. difference? if so, why reserve entire word that?
this
refers enclosing class instance. owner
refers directly enclosing object, may or may not enclosing class instance. example:
def x = { def y = { println this; println owner }; y() } x()
here this
refers instance of script class, , owner
refers x
.
Comments
Post a Comment