# Using return to terminate a function: Best Practices?

**URL:** <https://forum.kirupa.com/t/using-return-to-terminate-a-function-best-practices/236546>\
**Category:** Uncategorized\
**Created:** [August 21, 2007, 8:00pm UTC](https://forum.kirupa.com/t/using-return-to-terminate-a-function-best-practices/236546 "2007-08-21T20:00:22Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wilbur\_b7](https://avatars.discourse-cdn.com/v4/letter/w/4af34b/32.png) [@wilbur\_b7](https://forum.kirupa.com/u/wilbur_b7)\
**Post date:** [August 21, 2007, 8:00pm UTC](https://forum.kirupa.com/t/using-return-to-terminate-a-function-best-practices/236546/1 "2007-08-21T20:00:22Z")

</div>

with regard to _if(someCondition) return;_, i’m unclear on basic usage and best practices.

in the following, if any of the _if_ conditions are _true_ the function is terminated… makes sense. and i guess they’re still read in ascending order.

```auto
public function indexFunc(index:Number):Void
{        
    if (index < 0 ) return;
    if (index >= 10 ) return;
    if (index == currentIndex) return;
        trace("Okay, now do something.");
}

```

is this proper shorthand? a good practice? the reason i ask is that i can’t find this use of _return_ in the flash8 documentation… it only details using _return_ to specify a value returned by a function; never a mention of using it to terminate a function.

i’m new to custom classes and coding in general…

thanks for your help.
