Question

How do I create a variable with type List<String> in Xtend?

var list = Lists::newArrayList()
list.add( "xxx" )

doesn't work; the type in the add() isn't propagated back.

var list = Lists::newArrayList() as List<String>

gives an exception at runtime.

How do I create lists of a certain type in Xtend?

Was it helpful?

Solution

Which version of Xtend do you use?

var list = newArrayList
list.add('')

works for me (2.4.3).

Also var List<String> list = newArrayList will do the trick.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top