Hi, in a situation like this: <https://pl.kotl.in/...
# getting-started
t
Hi, in a situation like this: https://pl.kotl.in/vK8g6iJtG is there a way to implement this interface while keeping the
username
part of the primary ctor and without changing its name?
j
If the interface is defined in Kotlin, you should instead declare a property instead of a getter, then overriding it is simple:
Copy code
interface Foo {
    val username: String
}

data class User(override val username: String): Foo
t
unfortunately its defined in java
and not even by me, but by a library
j
Ah if it's Java then it will indeed be a problem, see: https://youtrack.jetbrains.com/issue/KT-6653
t
funny, thats even the very same interface i have problems with 😄
😆 1
thank you 🙂
n
You could use
@get:JvmName("getUsernameKt")
on the constructor parameter to avoid that conflict with the getUsername override method.
t
@Nick Allen awesome, thank you!