marcinmoskala
09/28/2018, 10:17 AMcketti
09/28/2018, 12:23 PMJonathan
09/28/2018, 1:04 PMign
argument, so why declaring the argument in the first place?marcinmoskala
09/28/2018, 1:23 PMNothing
would be easier and more clear 😕cketti
09/28/2018, 1:26 PMForceCallersToUseNamedParameters
. that'll make it somewhat clearmarcinmoskala
09/28/2018, 1:28 PM*,
. Also I think that it is not in the philosophy of Kotlin. In Kotlin, function user should decide if he prefers more or less explicitly. Sometimes it would be redundant if user would extract variable with the same say anyway. Though good rationale is that this way function designer can always change parameters order. On the other hand for this we now have inline classes that in most cases should help us from passing value to a wrong parameter... It is not so simple and I am just experimenting now 😄Nothing
parameter is translated to Void
so it should work with vararg
. No one really answered the question: why it is forbidden?cketti
09/28/2018, 2:27 PMAllan Wang
09/28/2018, 2:35 PMForceNamedParameters
as mentioned above), and take that as input. It better describes the situationobject ForceNamedParameters
fun aaa(forceNamedParameters: ForceNamedParameters = ForceNamedParameters, a: Int, b: Int) {
...
}
Jonathan
09/28/2018, 2:44 PMclass ForceNamedParameters private constructor()
. But even with a properly named parameter, declaring an argument which is not an actual argument obfuscate the code IMO. I think it's up to the user of the function to decide weather it is worthwhile or not to use named parameters. I don't understand the needs to enforce it.louiscad
09/28/2018, 6:30 PMvararg something: Nothing
was allowed, you could call it because you could call it with zero parameters. It's just an Array<Nothing>
under the hood, which can be empty.