#3 Avoiding multiple returns - Programming best practices

preview_player
Показать описание
Video demonstrates why multiple returns are bad and how to turn them into a single return.
Рекомендации по теме
Комментарии
Автор

I think, the example is really a bad one, as it is ok with multiple return statements. Very short and precise and with those returns, you can even get rid of the else keywords, reducing visual noise.

Multiple return statements may however, lead to problems with more complex functions and if you need to do something at the end of a function, like freeing up memory, this might lead to unnecessary, ugly and error prone redundancy.

MephistoDerPudel
welcome to shbcf.ru