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
Post a Comment