Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forums[xtend2] filter() and class selection
https://www.eclipse.org/forums/index.php/mv/msg/262672/758681/#msg_758681
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
all.filter(SomeClass)
should work. But it doesn't ("Couldn't resolve reference to JvmIdentifiableElement 'SomeClass'.").
What do I get wrong here?
Thanks in advance, regards,
Klaus
]]>Klaus Birken2011-11-24T08:33:38-00:00Re: [xtend2] filter() and class selection
https://www.eclipse.org/forums/index.php/mv/msg/262672/758682/#msg_758682
all.filter(typeof(SomeClass))
]]>Meinte Boersma2011-11-24T08:38:24-00:00Re: [xtend2] filter() and class selection
https://www.eclipse.org/forums/index.php/mv/msg/262672/758683/#msg_758683
Christian Dietrich2011-11-24T08:38:44-00:00Re: [xtend2] filter() and class selection
https://www.eclipse.org/forums/index.php/mv/msg/262672/758685/#msg_758685
]]>Klaus Birken2011-11-24T09:04:05-00:00Re: [xtend2] filter() and class selection
https://www.eclipse.org/forums/index.php/mv/msg/262672/758686/#msg_758686
(This is actually about another thread )]]>Meinte Boersma2011-11-24T09:16:07-00:00