Hello! How can I cast and run a method in Kotlin a...
# announcements
o
Hello! How can I cast and run a method in Kotlin as example in Java I need to do this:
Copy code
it as ImageButton
 it.rotateSmoothly()
Like this:
Copy code
(ImageButton) it.rotateSmoothly();
m
Copy code
(it as ImageButton).rotateSmoothly()
?
o
Yes, it is that I want. It works. Thanks)
p
do
(it as? ImageButton)?.rotateSmoothly()
to be safe
👍 1
e
or
if (it is ImageButton) it.rotateSmoothly()
to take advantage of the smart casting 😉
👍 1
👌 3