0

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?

Franz Kafka
  • 10,623
  • 20
  • 93
  • 149

1 Answers1

3

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

Stocker
  • 141
  • 6