views:

124

answers:

2

Hi,

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).

+4  A: 

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 ActionCcript.

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

frankhermes
thanks for the tip about `null`.
Derek Adair
+1  A: 

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.

greg
And you also lose performance.
Tegeril