Reflection: Get name of class/type
BlitzMax Forums/BlitzMax Beginners Area/Reflection: Get name of class/type
| ||
I thought this should work: Print TTypeId.ForObject(Self).Name() But it generates an "Unable to convert from 'Type' to 'Object'" error. Even tho Self should point to the object rather then the type according to the manual. Any Ideas ? Thanks. |
| ||
Self is no object reference |
| ||
Well, this is the description of "Self" in the manual: Reference to this Method's Object instance |
| ||
Are you trying to call that from a Function?SuperStrict Framework brl.blitz Import brl.standardio Import brl.reflection Local blah:TBlah = New TBlah blah.Test() Type TBlah Method Test() Print(TTypeId.ForObject(Self).Name()) End Method End Type I find it interesting that Max determines 'Self' to actually be a type in type functions (as it doesn't actually have any use). |
| ||
Wow you are right. I was calling it from a function. /facepalm ^^ Thanks ! |
| ||
Interesting, though mostly useless:SuperStrict Framework BRL.StandardIO Type T Function f:T() Return New Self End Function End Type If T.f() Print "Works!" |
| ||
Yeah, I assumed that was going to work. |