문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 | |||
|
groovy:closure [2019/01/22 19:52] kwon37xi |
groovy:closure [2019/01/22 19:53] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 7: | 줄 7: | ||
| ====== Method Reference ====== | ====== Method Reference ====== | ||
| * [[http:// | * [[http:// | ||
| + | <code groovy> | ||
| + | public class JavaObject { | ||
| + | | ||
| + | System.out.println(" | ||
| + | } | ||
| + | } | ||
| + | // Groovy method to convert to closure. | ||
| + | def groovySays(s) { | ||
| + | " | ||
| + | } | ||
| + | // Use .& syntax to convert method to closure. | ||
| + | names.each(this.& | ||
| + | |||
| + | // Convert Java method to closure and use it. | ||
| + | def javaSays = JavaObject.& | ||
| + | names.each javaSays | ||
| + | </ | ||