Groovy: what is analogue for java stream anyMatch

Rudziankoŭ :

What is Groovy analogue for following operation?

list.stream().anyMatch(b -> b == 0); 
Rao :

You mean to find if the list contains element 0?

def list = [0,1,2,3,4]
def result = list.any{it == 0}
println result

You can quickly try it online demo

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=458835&siteId=1