Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor the immediately returned variables #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

Refactor the immediately returned variables #3

wants to merge 2 commits into from

Conversation

yezz123
Copy link

@yezz123 yezz123 commented Sep 14, 2021

Returning the result directly shortens the code and removes an unnecessary variable, reducing the mental load of reading the function.
Where intermediate variables can be useful is if they then get used as a parameter or a condition, and the name can act as a comment on what the variable represents. In the case where you're returning it from a function, the function name is there to tell you what the result is

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant