I'm a PHP and ActionScript developer, and in some of my functions I use return
to end it. Example:
private function lolsome(a:String):void
{
if(a == "abs"){return void;}
// function's code
}
I could just place the function's code into its else
, but I prefer this way because in my opinion, this is more legible. I just want to know if this is considered a bad practice or something like that.
Thanks!
Nope. Not at all. It's often an important piece of control flow, in fact:
for x in someiterable:
if somecondition:
return somevalue
return None
This might come up if you were iterating over a sequence looking for something that satisfies a particular condition. If you find that something, you return it and prevent any further processing. If you never find it, you return a default value.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With