AS3中的无效点是什么?

the*_*gah 0 actionscript-3

这里有一个简单的问题,当void在AS3中跟随一个函数时它在做什么?

public function sayGoodbye():void { trace("Goodbye from MySubClass");}
Run Code Online (Sandbox Code Playgroud)

Pat*_*ick 5

void type向编译器指示您编写的函数不会返回任何值,如果您指示其他类型T而不是void,则编译器期望您返回T.

例如:

function foo(a:int):int { // here the compiler expect that somewhere
                          // in your function you return an int
 return a;
}
Run Code Online (Sandbox Code Playgroud)