David Harris wrote: > Hi everyone, > > I have a situation where I want to tell a value is of type date or not. > > Consider this: > > var b : Date; > > var s : String = describeType( b )[email protected](); > > Alert.show( > ( b is Date ).toString() > + "\n" > + ( typeof b ) > + "\n" > + ( s ) > ); > > > I get an alert of: > false > object > null > > if I do > var b : Date = new Date(); > > I get and alert of > true > object > Date > > Is there anyway I can work out a variable's type with out having to > declare a value in that variable? > No, and it doesn't make any sense to do so.
var b: Date; Tells the compiler that variable b is to be used to reference a Date object; It allows the compiler to make sure that you keep to that contract. By not assingning the variable b, you leave it referencing nothing - null; ( b is Date ) is now asking to check that a variable pointing at nothing (null) is a Date. It is not a Date, so the result is false. You ask about knowing the variables type - well you already do - you've told the compiler that b will hold a Date. For your purposes, the (something is Someclass) will always return false when something is a null reference - it cannot be any other result. Paul > cheers > > David > >

