I want to print an enum enum State{A(0),B(1)}
as a comma seperated list, in the form A=0, B=1
. For this xtext/xtend provides a join operation. However, I can't find any information on how to access multiple fields of the enum. The enum has a toString
and numVal
method.
E.g. {«State::values.join(', ') [toString»=«numVal]»}
does not work. What is the correct syntax for such an operation?
I think your double colon "::" is a problem.
println( State.values.join(', ')['''«toString»=«numVal»'''] )
works fine.
Or you can do it like this: println( State.values.map['''«toString»=«numVal»'''].join(', ') )
Both produce: A=0, B=1