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

Rule 5.2.3 Use default values for function arguments instead of overloading them #364

Closed
kentr0w opened this issue Oct 6, 2020 · 0 comments · Fixed by #370
Closed

Rule 5.2.3 Use default values for function arguments instead of overloading them #364

kentr0w opened this issue Oct 6, 2020 · 0 comments · Fixed by #370
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@kentr0w
Copy link
Collaborator

kentr0w commented Oct 6, 2020

In Java default values for function arguments were prohibited. That's why each time when it is needed to create a function with less arguments it should be overloaded. In Kotlin you can use default arguments instead.

Bad example

private fun foo(arg: Int) {
    // ...
}

private fun foo() {
    // ...
}

Good example

private fun foo(arg: Int = 0) {
     // ...
 }
@kentr0w kentr0w added the enhancement New feature or request label Oct 6, 2020
@kentr0w kentr0w added this to the Chapter 5 milestone Oct 6, 2020
@kentr0w kentr0w self-assigned this Oct 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant