【发布时间】:2017-05-18 20:30:32
【问题描述】:
我是 groovy 的新手(在 java 上工作),正在尝试使用 Spock 框架编写一些测试用例。 我需要使用“每个循环”将以下 Java sn-p 转换为 groovy sn-p
Java 代码段:
List<String> myList = Arrays.asList("Hello", "World!", "How", "Are", "You");
for( String myObj : myList){
if(myObj==null) {
continue; // need to convert this part in groovy using each loop
}
System.out.println("My Object is "+ myObj);
}
Groovy 片段:
def myObj = ["Hello", "World!", "How", "Are", "You"]
myList.each{ myObj->
if(myObj==null){
//here I need to continue
}
println("My Object is " + myObj)
}
【问题讨论】:
标签: for-loop groovy each continue