https://kotlinlang.org logo
Title
a

adk

03/12/2020, 9:30 AM
It looks like you are calling print inside your functions, rather than having your functions return a value to be interpolated by the calling print statement.
i.e. your code looks a bit like this:
val myInterfaceObject = InterfaceImplementation()

class InterfaceImplementation: SomeInterface {
    override fun displayInfo() {
        println("Hello from the displayInfo")
    }

    override fun dispayMoreContent() {
        print("This is more content")
    }

    override val myName: String
        get() = "value"

}

interface SomeInterface {
    fun displayInfo()
    fun dispayMoreContent()

    val myName: String
}


println("My Variable value is ${myInterfaceObject.myName}")
println("Call the displayInfo ${myInterfaceObject.displayInfo()}")
println("Call the interface method ${myInterfaceObject.dispayMoreContent()}")
When it should look something like this:
val myInterfaceObject = InterfaceImplementation()

class InterfaceImplementation: SomeInterface {
    override fun displayInfo(): String {
        return "Hello from the displayInfo"
    }

    override fun dispayMoreContent(): String {
        return "This is more content"
    }

    override val myName: String
        get() = "value"

}

interface SomeInterface {
    fun displayInfo(): String
    fun dispayMoreContent(): String

    val myName: String
}


println("My Variable value is ${myInterfaceObject.myName}")
println("Call the displayInfo ${myInterfaceObject.displayInfo()}")
println("Call the interface method ${myInterfaceObject.dispayMoreContent()}")