[Groovy] foreach..break 테스트

ITWeb/개발일반 2017. 10. 31. 16:03

[foreach.groovy]

def list = ["A", "B", "C", "D"]


list.each {

  println it


  if ( it.indexOf("B") > -1 ) return true

}

println "---------------"

list.any {

  println it


  if ( it.indexOf("B") > -1 ) return true

}


[Result]

A

B

C

D

---------------

A

B


: