Translate

Tuesday 5 October 2021

Scope of Delegate in Groovy Scripting groovy trainig telugu 28

 Watch This Video

https://youtu.be/56TcvetOsg4

------------------------------------------------------------------------------------------------------------------

class ScopeDemo{
def outerClosure ={
println this.class.name
println owner.class.name
println delegate.class.name
def innerClosure={
println this.class.name
println owner.class.name
println delegate.class.name
}
innerClosure()
}
}
def demo=new ScopeDemo()

//other Example

def writer={
append 'Dan'
append 'lives in USA'

}

def append(String s){

println "append() called with argument of $s"
}

StringBuffer sb= new StringBuffer()
writer.resolveStrategy=Closure.DELEGATE_FIRST
writer.delegate=sb
writer()




No comments:

Post a Comment

Note: only a member of this blog may post a comment.