Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // closure sin argumentos
- def hola = {println "hola"}
- hola()
- // closure con un sólo argumento
- def saludo = {println "hola $it"}
- saludo("Fátima")
- // closure con dos argumentos
- def printSum = { a, b -> println a+b }
- printSum( 5, 7 )
- // closure con variables libres
- def a = 10
- def sum10 = { it + a}
- println sum10(5)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement