Hey guys ... am trying to convert Any to an Object...
# android
k
Hey guys ... am trying to convert Any to an Object Class Any Idea ?
Copy code
fun bindview(pool:Any){
//want to convert 
}
I have my class
class Users(var name, var id)
m
Why do you need the conversion? In Kotlin, we don't have
Object
, so
Any
will work fine. If you have a Java API and should pass an
Object
instance, you can pass the
Any
as it is and the compiler will make it work.
k
What if i have an object class and i want to access some parameters inside ?
m
Are you trying to cast the
pool
as another type, let's say
Pool
?
You can use the safe-cast operator
as?
Copy code
(pool as? Pool)?.doSomething()
k
am trying val x: groupA = model as groupA
what about Any to an arraylist
?
e
Just the same thing, use
as
k
No is not working ...
e
You want casting or a actual conversion?