I have a problem with understanding how to implement extension function, which calls other functions inside the class. My goal is to implement extension function that calls in this case open(), find() and close().
Fridge class is as follows:
class Fridge {
fun open() = println(1)
fun find(productName: String): Product {
println(productName)
return 4
}
fun close() = println(3)
}
I have no problem with writing single extension function lets say:
fun Double.addInt(i: Int) = this + i.toDouble()
But I'm confused with multiple funcions at once, also specified return type gets me confused. What I have is:
fun Fridge.take(productName: String): Product {
open()
find(productName)
close()
//return this.find(productName)
}
Where have i made a mistake? Right now I guess it's return type, but how to return Product?
(This is a task from hyperskill )
