If you use findAll
without parameters. It will return every "true" value, so this should work:
def ans = [part1, part2, part3].findAll().join()
Note that findAll
will filter out empty lines (because they are calculated as false in a boolean context), but in this case it does not matter, since empty lines do not add anything to join()
:)
If this is a simplified question, and you want to keep empty string values, you can use findResults
{ it }
.
source share