Kotlin / kotlin-koans

Kotlin workshop
MIT License
2.6k stars 1.41k forks source link

Use spread operator for named vararg #120

Closed aksh1618 closed 6 years ago

aksh1618 commented 6 years ago

This was giving the warning 'Assigning single elements to varargs in named form is deprecated.' in IntelliJ IDEA.

jarekankowski commented 6 years ago

The warning could also be solved by swapping the arguments with which the order function is called and not using the products named argument. You can see an example of this solution in the TestShop.kt file (lines 49 and 50). Regardless of the chosen solution, I would recommend keeping the code consistent.

aksh1618 commented 6 years ago

@jarekankowski Although I was aware of both, I chose this solution as this would show a learner an alternative way to call a function with named varargs. It remains to be decided whether this takes precedence over consistency.

svtk commented 6 years ago

aksh1618, thanks for noticing this problem! I've fixed it in a way mentioned by @jarekankowski