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?

有帮助吗?

解决方案

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

or even

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

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top