Skip to main content
added 231 characters in body; added 1 character in body; added 1 character in body
Source Link

I am far from an expert in Kotlin, but it seems that your problem is using the by keyword here. AuthHost should hold a member of type Auth, but here you're saying that AuthHost itself implements Auth, and delegates that implementation (that's what the by keyword states) to GoogleAuth, explicitly.

What you need to do is instantiate the Auth class you need, and call the relevant one depending on the method called.

 class AuthHost  { 
    val auth : hashMapOf<string, Auth>

    fun onGoogleClick() {
          auth[google].doAuth() ​
    ​} 
    fun onTwitterClick() {
          auth[twitter].doAuth()
    }
} 

I am far from an expert in Kotlin, but it seems that your problem is using the by keyword here. AuthHost should hold a member of type Auth, but here you're saying that AuthHost itself implements Auth, and delegates that implementation (that's what the by keyword states) to GoogleAuth, explicitly.

What you need to do is instantiate the Auth class you need, and call the relevant one depending on the method called.

I am far from an expert in Kotlin, but it seems that your problem is using the by keyword here. AuthHost should hold a member of type Auth, but here you're saying that AuthHost itself implements Auth, and delegates that implementation (that's what the by keyword states) to GoogleAuth, explicitly.

What you need to do is instantiate the Auth class you need, and call the relevant one depending on the method called.

 class AuthHost  { 
    val auth : hashMapOf<string, Auth>

    fun onGoogleClick() {
          auth[google].doAuth() ​
    ​} 
    fun onTwitterClick() {
          auth[twitter].doAuth()
    }
} 
Source Link

I am far from an expert in Kotlin, but it seems that your problem is using the by keyword here. AuthHost should hold a member of type Auth, but here you're saying that AuthHost itself implements Auth, and delegates that implementation (that's what the by keyword states) to GoogleAuth, explicitly.

What you need to do is instantiate the Auth class you need, and call the relevant one depending on the method called.