| [ Web Proxy ] |
| Viewing: https://riptutorial.com/actionscript-3/example/9469/annotating-types | [Back] [Original] |
[logo rip]
You can tell the compiler the type of a value by annotating it with :Type:
var value:int = 10; // A property "value" of type "int".
Function parameters and return types can also be annotated:
// This function accepts two ints and returns an int.
function sum(a:int, b:int):int {
return a + b;
}
Attempting to assign a value with a mismatching type will result in a TypeError:
var sprite:Sprite = 10; // 10 is not a Sprite.
| Web Proxy Viewer | New URL | Original Page |