我是groovy的新手(在java上工作),尝试使用Spock框架编写一些测试用例.我需要使用"每个循环"将以下Java代码段转换为groovy代码段
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);
}
Run Code Online (Sandbox Code Playgroud)
Groovy Snippet:
def myObj = ["Hello", "World!", "How", "Are", "You"]
myList.each{ myObj->
if(myObj==null){
//here I need to continue
}
println("My Object is " + myObj)
}
Run Code Online (Sandbox Code Playgroud)