I want to wrap each list item in single quotes and concatenate them into a string.
Input Example: ["aa", "bb", "cc"]
Expected Result: "'aa', 'bb', 'cc'"
I figured that this could be done using closure +, so I tried:
def mylist = ["aa", "bb", "cc"] println mylist.collect{ 'it' }.join(', ')
But the conclusion is: "it, it, it" , and that is not what I want.
How can I add and pre-set a single quote for each list item? Any other oneliner (or short) groovy solutions other than collecting and combining?
source share