声明为*(星号)ActionScript变量类型 [英] Actionscript variable declared as * (star) type

查看:170
本文介绍了声明为*(星号)ActionScript变量类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到的地方下面的语句 -

I saw following statement somewhere -

var someVariable:*;

为什么 someVariable 的声明为*(星号)类型?有什么用声明这样说吗?

Why is someVariable declared as * (star) type? What is the use of declaring it this way?

推荐答案

之间的实际差异 * 对象 * 未定义,而对象不能。

The practical difference between * and Object is that * can be undefined whereas Object cannot.

该文档已说:

指定属性是无类型。使用星号的类型注释等效于使用任何类型的注解。从类型化属性读取前pressions被视为无类型EX pressions。使用无类型EX pressions或属性,建议在以下情况:

Specifies that a property is untyped. Use of the asterisk symbol for a type annotation is equivalent to using no type annotation. Expressions that read from untyped properties are considered untyped expressions. Use of untyped expressions or properties is recommended in the following circumstances:

      
  • 当你想推迟类型检查到运行时。您可以使用无类型属性或EX pression规避编译时类型检查的严格模式。但是请注意,赋值语句的运行时类型检查时是否使用严格模式还是不行。

  • When you want to defer type checking to runtime. You can use an untyped property or expression to circumvent compile-time type checking in strict mode. Note, however, that runtime type checking of assignment statements occurs whether you use strict mode or not.

当你想存储未定义的属性的值。与ActionScript的previous版本,值undefined不是Object数据类型的成员。您必须使用无类型属性来存储值undefined。

When you want to store the value undefined in a property. Unlike previous versions of ActionScript, the value undefined is not a member of the Object data type. You must use an untyped property to store the value undefined.

这篇关于声明为*(星号)ActionScript变量类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆