0

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?

Charles Henry
  • 353
  • 3
  • 16

1 Answers1

0

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

or even

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

Jon
  • 398
  • 1
  • 11
  • Thank you very much this is what I was looking for but I still have a problem. How would I output the following? ClassName name2, ClassName name3, ClassName name4 – Charles Henry Feb 17 '13 at 22:46
  • I'm struggling to see how that differs from your original question. If you mean "without the first attribute's info" then `... e.attributes.tail ...`, or perhaps you mean `...', '»ClassName «a.eClass.name» ...` – Jon Feb 19 '13 at 12:18