|[xtend2] filter() and class selection [message #758681]
||Thu, 24 November 2011 08:33
| Klaus Birken
Registered: November 2011
I started using Xtend2 for transformation and generation recently, it is a great and elegant language!
However, I guess I didn't understand all language concepts so far. The following question arises: In order to select all elements from a list which are instances of a certain class I am using this code:
var List<MyBaseClass> all = ...
all.filter(m | m instanceof SomeClass).map(m | m as SomeClass)
The filter selects the elements, but returns a Iterable<MyBaseClass>. The map() casts this to Iterable<SomeClass>, which is what I want to have.
I guess there might be a shorter way to do this... reading the online doc I think
should work. But it doesn't ("Couldn't resolve reference to JvmIdentifiableElement 'SomeClass'.").
What do I get wrong here?
Thanks in advance, regards,
[Updated on: Thu, 24 November 2011 08:35]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.02195 seconds