문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 다음 판 | 이전 판 | ||
|
groovy:제어문 [2012/11/30 12:17] kwon37xi 새로 만듦 |
groovy:제어문 [2013/05/17 14:50] (현재) kwon37xi [for] |
||
|---|---|---|---|
| 줄 2: | 줄 2: | ||
| * [[http:// | * [[http:// | ||
| * http:// | * http:// | ||
| + | * [[http:// | ||
| + | ===== for ===== | ||
| + | * for 문은 거의 사용할 일이 없다. | ||
| + | * Index가 필요한 for 문은 '' | ||
| + | def stringList = [ " | ||
| + | " | ||
| + | |||
| + | stringList.eachWithIndex() { obj, i -> println " ${i}: ${obj}" | ||
| + | </ | ||
| ===== switch/case ===== | ===== switch/case ===== | ||
| * case 에는 '' | * case 에는 '' | ||
| + | * [[http:// | ||
| + | class CaseCategory { | ||
| + | static boolean isCase(Closure casePredicate, | ||
| + | casePredicate.call switchParameter | ||
| + | } | ||
| + | } | ||
| - | ==== Functional | + | use (CaseCategory) { |
| - | * http:// | + | switch (param) { |
| + | case { it % 2 == 0 } : return ' | ||
| + | | ||
| + | case { 0 < it } | ||
| + | default | ||
| + | } | ||
| + | } | ||
| + | </code> | ||