Question

I have some Xtend code that outputs data. Here is the code below:

«FOR a:e.attributes»
    «a.eClass.name» «a.name»,
«ENDFOR»

This would output something like:

ClassName name1, ClassName name2, ClassName name3, ClassName name4,

My Desired Output is:

ClassName name1, ClassName name2, ClassName name3, ClassName name4

Note that there is no comma at the end of the line on the desired output. Is it possible to implement a function in Xtend that will allow me to not output the last comma?

Was it helpful?

Solution

«FOR a:e.attributes SEPARATOR ', '»«a.eClass.name» «a.name»«ENDFOR»

or even

e.attributes.map['''«eClass.name» «name»'''].join(', ')

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top