Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » [xtend2] cast of lists
[xtend2] cast of lists [message #718243] Tue, 23 August 2011 17:40 Go to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Hi there,

how do I cast a list to a more specific list, e.g.

Iterable<A> a
a as Iterable<B>

does not show an Error in the Xtend2 Editor, but it gives a compile
Error in the generated Java, of course. (Is the missing error a bug?)

However, something like

a.map(as B)

is not possible either. Is there no proper cast-function that could be
used in the map?

Is there any other solution than the verbose one of manually iterating 'a'?

Cheers,
Hauke
Re: [xtend2] cast of lists [message #718244 is a reply to message #718243] Tue, 23 August 2011 17:47 Go to previous messageGo to next message
Hauke Fuhrmann is currently offline Hauke FuhrmannFriend
Messages: 333
Registered: July 2009
Senior Member
Revoke.

> a.map(as B)

a.map(o | o as B)

seems to work
Re: [xtend2] cast of lists [message #718253 is a reply to message #718244] Tue, 23 August 2011 18:11 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 13882
Registered: July 2009
Senior Member
alternatively you can do a typesafe filter(typeof(B))

Need professional support for Xtext, Xpand, EMF?
Go to: https://www.itemis.com/en/it-services/methods-and-tools/xtext
Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:GMF synchronization with XTEXT2
Next Topic:Creating new EObjects from XtextResource
Goto Forum:
  


Current Time: Tue Apr 13 19:46:28 GMT 2021

Powered by FUDForum. Page generated in 0.02175 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top