标签: list groovy
def names = ["myname", "yourname", "theirname", "allnames"] String n = "" names.each{ n += it + "," } println n
输出:
myname,yourname,theirname,allnames,
如何摆脱尾随的逗号?
答案 0 :(得分:17)
names.join(",")