Charles Henry
Charles Henry

Reputation: 373

Xtend for loop (desired while loop function)

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?

Upvotes: 0

Views: 579

Answers (1)

Jon
Jon

Reputation: 398

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

or even

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

Upvotes: 0

Related Questions