I am new to groovy (worked on java), trying to write some test cases using Spock framework. I need the following Java snippet converted into groovy snippet using "each loop"
Java Snippet:
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 Snippet:
def myObj = ["Hello", "World!", "How", "Are", "You"]
myList.each{ myObj->
if(myObj==null){
//here I need to continue
}
println("My Object is " + myObj)
}
question from:https://stackoverflow.com/questions/41465691/how-to-use-continue-in-groovys-each-loop