How to get the type of an object?

780 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Freewind

ungelesen,
18.06.2012, 13:02:4118.06.12
an xtend...@googlegroups.com
I have an instance of some class, how to get its type?

In java:

    obj.getClass()

How to do it in xtend?

Sebastian Zarnekow

ungelesen,
18.06.2012, 13:05:4518.06.12
an xtend...@googlegroups.com
Did you try obj.getClass() ? ;-)
signature.asc

Sven Efftinge

ungelesen,
18.06.2012, 13:07:1718.06.12
an xtend...@googlegroups.com
obj.getClass()

:-)

also

obj.getClass

and

obj.^class

(the '^' is required to escape identifiers conflicting with keywords)

The reason why you didn't find it in the first place, is that content assist doesn't propose it.
It's know bug and will be fixed soon.

Sven

Freewind

ungelesen,
18.06.2012, 13:07:3918.06.12
an xtend...@googlegroups.com
You are right :-p

Zsombor

ungelesen,
18.06.2012, 13:08:0418.06.12
an xtend...@googlegroups.com

It's a pretty common question, as it doesn't have an obvious solution. Is there any fundemantal issue, supporting the java like myObj.getClass and String.class expressions?

Regards
Zsombor

Sebastian Zarnekow

ungelesen,
18.06.2012, 13:28:5118.06.12
an xtend...@googlegroups.com
obj.getClass does the job as expected. String.class was more difficult to get right from a technical perspective thus we decided to go for typeof(String) instead. I actually prefer that syntax over String.class.

Regards,
Sebastian
signature.asc
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten