0

考虑

var s: String = null;

在这种情况下,是否有一个函数接受一个对象,例如s并产生静态类型名称(声明对象时使用的名称)String

到目前为止我一直在使用getQualifiedClassName(),但只是注意到它不适用于null值 - 我想知道是否有类似的东西不会尝试确定动态类型而是“静态”类型(以防 Flex 做出这种区分...)。

4

1 回答 1

1

You cannot get "static" type once you compile your project, because every type at runtime is dynamic, and coercion is widely used to determine which type is this object. Null objects are just that, you cannot get anything out of a null value. So, either assign a kind of default value for such objects you need to be checked for type at runtime, or store a proper type (a variable of type Class) alongside such an object.

于 2012-11-20T10:27:52.007 回答