开发者

Actionscript 3 return types - is a * return type ok to use?

I have a function in which I'd li开发者_如何学Goke to return an Object or false.

Is a return type of * ok to use? are there any downfalls to this? (besides it being a bit lazy in some cases).


You could also return null instead of false. Then your return type could still be Object.

For my taste, an Object is still too vague. Almost everything is an Object in ActionScript.

The more specific your types, the more errors are caught by the compiler before you run it. Strict typing is your friend!


Yeah. * is a perfectly acceptable return type.
The downfall is that you'll no longer have compile time checking for the return type of that function. The compiler wont be able to tell if you're using it wrong. Also you're code might be less readable as the result of the function may be less obvious.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜