# AS2: What datatype should a function return, if it may not return \*anything\*?

**URL:** https://forum.kirupa.com/t/as2-what-datatype-should-a-function-return-if-it-may-not-return-anything/222917
**Category:** flash
**Created:** [April 17, 2007, 11:07pm UTC](https://forum.kirupa.com/t/as2-what-datatype-should-a-function-return-if-it-may-not-return-anything/222917 "2007-04-17T23:07:50Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![Aesir](https://avatars.discourse-cdn.com/v4/letter/a/e19adc/32.png) [@Aesir](https://forum.kirupa.com/u/Aesir)
#### Post date: [April 17, 2007, 11:07pm UTC](https://forum.kirupa.com/t/as2-what-datatype-should-a-function-return-if-it-may-not-return-anything/222917/1 "2007-04-17T23:07:50Z")

</div>

[COLOR=black][FONT=Arial]The title of this post may not make much sense, let me explain…[/FONT][/COLOR]

[COLOR=black][FONT=Arial]I have a function:[/FONT][/COLOR]

[COLOR=black][FONT=Arial]_findSurface(origin:Point, vector:Point, attempts:Number):Point {…}_[/FONT][/COLOR]

[COLOR=black][FONT=Arial]The function has an obscure use, but the idea is thus: **given those three arguments, returns a point IF the ‘line’ (created by the origin and vector arguments) intersects the object the function is called on.** [but that is another story…][/FONT][/COLOR]

[COLOR=black][FONT=Arial] **More importantly, if there is no point of intersection at all, what should the function return?** Void? Null? Undefined? Object? Or can I use one of those return types instead of Point incase the function does not encounter an intersection?[/FONT][/COLOR]

[COLOR=black][FONT=Arial]I’d be glad to try explaining better if anyone might know, thanks.[/FONT][/COLOR]
