9.5 Class variables

Class variables are defined using the var or const keywords.

class A
{
    var x
    const k = 10
}

The meaning of var and const follow from the general meaning described in the sections 7 Variables and 1.4 Variables.

var

May be written to multiple times

const

May be written to only once

const variable properties can be written to only once. The compiler uses a specific data flow analysis to determine if a const variable has been written to at the point of an assignment to that variable. Informally, the effect of this algorithm can be seen in the following error cases:

The default value of a class or instance variable is the value of undefined coerced to the type of the variable.


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/specs/actionscript/3/as3_specification85.html