-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Add explicit return type to some methods #4937
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
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hello, and thank you for opening this PR! 🎉
All contributors have signed the CLA, thank you! ❤️
Have an awesome day! ☀️
Hi! Thanks for your PR, but how have you picked which methods to add a return type for? That's really not obvious to me, nor it is whether these methods need a return type. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have a strong opinion but would argue that adding : Boolean
to an is..
method is redundant. Similarly for : Unit
. For the others, the change looks like an improvement in legibility.
@Blaisorblade Hi. I think all public methods (private in some cases) should have explicit return type. in general. The reasons are below:
In this PR, I picked several methods that the return types are inferred experimentally. If it's permitted, I'll try to add explicit return type to all public methods. @odersky I think |
Agree with most of those arguments, except that there's no binary compatibility to speak of (tho unneeded recompilation stands). Let's see what the others say — e.g. @allanrenucci, @smarter, what do you think? |
I usually only add explicit return type to public members. I can see value in adding explicit return type to private/local side effect-full methods that return However in general, I would not add explicit return type to private/local methods (and local variables). These methods are usually fairly small and it makes the code more verbose and sometime less readable. But that's my opinion 😄 |
@allanrenucci I agree with you opinion (should not add explict return type to private/local methods). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's been a month... @kmizu If you plan to continue working on this PR please reopen (or make a new one), I will close it for now. |
@OlivierBlanvillain I'm very sorry to forget it. Later, I'll continue working on this PR and reopen this PR (or make a new one). |
Hi, @smarter. I understand that this PR shouldn't be needed anymore. Thanks. |
I think the code is more readable if a return type of a method is not omitted generally