Question

I have a function in which I'd like 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).

Was it helpful?

Solution

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!

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top