https://kotlinlang.org logo
#language-proposals
Title
# language-proposals
v

voddan

09/01/2017, 1:10 PM
@natpryce I would solve your example by overloading
printStat
to accept
Score
directly. Assuming this did not work for you real use case, what was the problem with it?
b

benleggiero

09/01/2017, 1:29 PM
He said that's like his current solution, but it's so much boilerplate it leaves a bad taste in his mouth [my words]
v

voddan

09/01/2017, 8:31 PM
I really don't get it. If we raise the level of abstraction by combining values into data classes and then working with those classes, it should be reflected in the code. Since the function
fun printStat(score: Score)
I proposed should only be written once, I can't count it as boilerplate.
b

benleggiero

09/05/2017, 1:43 AM
Yes, the particular function would be written once, but I get the sense that this is a common thing he does. For example, an
equals
function is something you only write once, but that "once" is multiplied across all classes. This is why it's generated in `data class`es. The same argument can be applied to this: Why require them to write a specialized function that takes in a specialized type and generifies it for every specialized type, when you can just make the generified functions destruct a
data class
?
v

voddan

09/05/2017, 4:38 AM
I was trying to understand the scale of the problem
b

benleggiero

09/05/2017, 5:01 PM
My guess is that this pattern would be as common as a
for
loop
4 Views