All posts filed under “Rust

comment 0

8 reasons why implicit return in modern languages is wrong

Some languages allow, or even force you, to declare your return statement in your function without any visual difference, only by being the last statement in the function. This is what we can call implicit return.

This covers languages such as Rust, Javascript, Ruby, or even or old Bash.

This article gives 8 reasons on why this is a bad design and should be avoided at all costs for general code, and give the only acceptable case where return might be avoided. For readability and maintainance sake, always use the return  keyword of your language in your functions. Always.