Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create comma-separated list in xtend

Tags:

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.

like image 447
moin moin Avatar asked Mar 11 '13 14:03

moin moin


2 Answers

You may want to try

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

or

row.params.join(',') [ value ]
like image 145
Sebastian Zarnekow Avatar answered Sep 22 '22 13:09

Sebastian Zarnekow


Something like

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

should do the trick. I put spaces before and after double quotes only to help you seeing each chars, but you may want to delete them.

like image 28
Antwane Avatar answered Sep 24 '22 13:09

Antwane