Answer the question
In order to leave comments, you need to log in
Is it possible to implement this in Kotlin?
Good afternoon!
I have an interface in which I describe a function and in this function I have a variable with a default value.
Next, I created a class that implements this interface with this function, how can I reach this variable in the class?
Here is an example code:
interface MyFun{
fun testVal(){
val text: String = "deasdasd"
}
}
class TestText() : MyFun {
override fun testVal() {
println(text) // как мне тут получить это значение которое я определил в интерфейсе?
}
}
Answer the question
In order to leave comments, you need to log in
You can make a method with a default implementation that will return your string.
https://kotlinlang.org/docs/interfaces.html#proper...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question