Search code examples
xtend

create comma-separated list in xtend


I am learning xtend. What would be a nice way to create a comma separated list in xtend? (something like the SEPARATOR in xpand)

I want to produce a comma separated list of parameters in my generator:

«FOR param: row.params»
     "«param.value»",
«ENDFOR»

This works but I need to omit the last comma. I tried row.params.join(",") as well but then the quotes are missing.


Solution

  • You may want to try

    «FOR param: row.params SEPARATOR ','»
         "«param.value»"
    «ENDFOR»
    

    or

    row.params.join(',') [ value ]