Watch This Video
def c ={}
println c.class.name
println c instanceof Closure
def sayHelo={ name ->
println "Hello $name"
}
sayHello('rashmi')
List num=[3,4,5,6,7]
num.each({ nums ->
println nums
})
//closures are object
def timesTen(num,closure){
closure{num *10}
}
timesTen(10,{println it})
timesTen(2,{println it})
No comments:
Post a Comment
Note: only a member of this blog may post a comment.