-
Notifications
You must be signed in to change notification settings - Fork 7
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
Avoid using vararg in API #30
Comments
As far as I can tell, the only API methods that use vararg are also the ones where its use is unavoidable, like the general getter/setter methods. Which methods were meant exactly? |
It is better to use |
So you're saying that we should provide both
The vararg setter can be called in two ways:
No manual spreading and array-creation is required in either of them. This probably should be explicitly mentioned in the KDoc, though. |
Turns out we can't provide both |
It is easily solved by @JvmName annotation. Even better - you can move vararg one to extensions. Here is the example. |
About setter, you are correct. My problem was with this construct: |
I wonder why does the extension approach work, while defining the method inside the class does not. |
|
Because extension is a static method in |
Also, |
Not |
Both because it complicates function calls, especially when vararg is not the last argument. Also there is possible performance impact because of array re-wrapping in kotlin.
The text was updated successfully, but these errors were encountered: