Reputation: 3027
How can I loop through a list of values, including each one into a Groovy multi-line string?
myList = ['one', 'two', 'three']
myString = """
some text
${for(item in myList){item}}
some more text
"""
Upvotes: 1
Views: 528
Reputation: 25873
Using List.join
static void main(String[] args) {
def myList = ['one', 'two', 'three']
def myString = """
some text
${myList.join()}
some more text
"""
println myString
}
Upvotes: 1