James
09/18/2018, 10:26 AMpublic interface Identifiable<T> {
T getId();
}
I've tried the following...
class Product(override val id: String): Identifiable<String>
But i get an error id overrides nothing
Then I tried:
class Product(val id: String): Identifiable<String> {
fun getId(): String = id
}
But, of course, you get a JVM conflict The following declarations have the same JVM signature 'public final <get-id>(): String' and 'public open getId(): String'
I found that making id
private works but that's less than ideal:
class Product(private val id: String): Identifiable<String> {
fun getId(): String = id
}
Andreas Sinz
09/18/2018, 10:38 AMAndreas Sinz
09/18/2018, 10:42 AMJames
09/18/2018, 3:27 PM