Reputation: 53
i'm new with kotlin , i got one problem with interface in kotlin , there is my interface
interface Products{
fun Succes(res:Product)
fun Error(msg:String)
}
i used this interface in constructor of some function like this
fun homeProducts(url: String, onRecived: Interfaces.Products){}
i did set value in this function ( homeProduct ) and i know its working fine , but problem is i cant imp this interface inside function
ServerCalls(this).homeProducts(url,onRecived = {
// this is problem
} )
any idea's?
Upvotes: 0
Views: 75
Reputation: 56
You can use an object expression, like this:
ServerCalls(this).homeProducts(url, onRecived = object: Products {
override fun Succes(res: Product) {
}
override fun Error(msg: String) {
}
})
Upvotes: 4