사용자 도구

사이트 도구


groovy:closure

Groovy Closure

Method Reference

public class JavaObject {
 public static void javaSays(final String s) {
  System.out.println("Java says: Hello " + s + "!");
 }
}
 
// Groovy method to convert to closure.
def groovySays(s) {
 "Groovy says: Hello ${s}!"
}
// Use .& syntax to convert method to closure.
names.each(this.&groovySays)
 
// Convert Java method to closure and use it.
def javaSays = JavaObject.&javaSays
names.each javaSays
groovy/closure.txt · 마지막으로 수정됨: 2019/01/22 19:53 저자 kwon37xi