DEV Community

Discussion on: Ditching the "else" Statement

Collapse
 
assunluis80 profile image
Luís Assunção • Edited

Exactly! When I was a CS student, I remember the teachers stressing out about multiple return statements... It completely changes the internal organization of compilers.

Beside of that, I would write the first example as just:

return (value1 === value2); 😎

Collapse
 
mkovace profile image
Michael Kovacevich

Yea I pointed out that the function itself is useless, but it serves as a simple example.

As far as it's effects on the compiler, I'd say it very much depends on the language and the use case. Also in my 7 years in industry I've never had to take a minor compiler optimization like that into consideration.