It's considered a bad pratice use return to end a function?

后端 未结 5 1160
忘了有多久
忘了有多久 2021-01-19 10:46

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
{
           


        
5条回答
  •  借酒劲吻你
    2021-01-19 11:17

    I use it when i'm too lazy to declare a flag and test it. But the fact is: If you use break, return, and that kind of instructions in the middle of your code, you will sometimes have to refactor it when adding functionnalities.

    So I consider it a bad practice, but very much used. Well it's just my opinion :p

提交回复
热议问题