Using "any" function in groovy always return the result of the last item closure -


i'm trying following :

"""foo bar""".eachline { line ->     ['foo', 'baz'].any{         println(it + ' - ' + line)         line ==     } } 

result :

foo - foo foo - bar baz - bar false 

i test if of lines of multiline string

"""foo bar""" 

is present in array ['foo', 'baz'].

but here returns false event if foo present in string.

what doing wrong ?

try:

"""foo bar""".split('\\n').any { line -> ['foo', 'baz'].contains(line)} 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -