[haXe] Using Type.typeof

John Eriksson john at insane.se
Wed Aug 1 16:00:10 CEST 2007


Yeah, I thought so too, but it doesn't exist. TObject is declared in
Type.hx, so I tried
import Type;

But I still can't declare a variable to be of type TObject.

Std.is doesn't seem to work properly... if I import Type; I have
tried(without compiler errors now):

var h = {a: 'hhh',b:'aaa'};
		
trace('is it: '+Std.string(Std.is(h, TObject)));
returns false

trace('it is: '+Std.string(Type.typeof(h)));
returns TObject

?!

It now claims it is not a TObject and also claims it is...


2007/8/1, Ian Liu <ian.liu88 at gmail.com>:
> I think you should import ValueType, even if it is in "level 0" package.
>
>
> On 8/1/07, Benjamin Dasnois < benjamin.dasnois at gmail.com> wrote:
> > Maybe it works but you're using another function...
> > Are you sure you've included what's necessary for your TObject type to
> > be accessible? For example, does the compiler complains if you try to
> > declare a variable of type TObject in the same function?!
> >
> >
> >
> > On 8/1/07, John Eriksson <john at insane.se> wrote:
> > > I tried it, but it gives me this error when compiling:
> > >
> > >
> ../frameworks.git/InsaneFramework/se/insane/core/model/INSModelArray.hx:39:
> > > characters 24-31 : Unknown identifier : TObject
> > >
> > > currently I am doing:
> > >
> > > if(Std.string(Type.typeof(fieldData)) == 'TObject')
> > >
> > > is that really how it is supposed to work?
> > >
> > > 2007/8/1, Benjamin Dasnois <benjamin.dasnois at gmail.com>:
> > > > Hello,
> > > > Try this :
> > > > if (Std.is(fieldData, TObject))
> > > > {
> > > >    //fieldData is of type TObject
> > > > } else
> > > > {
> > > >   //fieldData is not of type TObject
> > > > }
> > > >
> > > > Regards,
> > > > Benjamin DASNOIS
> > > >
> > > > On 8/1/07, John Axel Eriksson <john at insane.se> wrote:
> > > > > If I'd like to compare the type of a value and check if it is
> > > > > TObject, how would I do that?
> > > > >
> > > > >
> > > > > I have tried:
> > > > >
> > > > > if ( Type.typeof(fieldData) == TObject )
> > > > >
> > > > > if ( Type.typeof(fieldData) == "TObject" )
> > > > >
> > > > > if ( Type.typeof(fieldData) == ValueType.TObject )
> > > > >
> > > > > and some other ways but none of these are correct. I guess this is a
> > > > > simple one, but I can't seem to figure it out.
> > > > >
> > > > >
> > > > > /J
> > > > >
> > > > > --
> > > > > haXe - an open source web programming language
> > > > > http://haxe.org
> > > > >
> > > >
> > > > --
> > > > haXe - an open source web programming language
> > > > http://haxe.org
> > > >
> > >
> > > --
> > > haXe - an open source web programming language
> > > http://haxe.org
> > >
> >
> > --
> > haXe - an open source web programming language
> > http://haxe.org
> >
>
>
> --
> haXe - an open source web programming language
> http://haxe.org
>



More information about the Haxe mailing list