I came across this in a Kotlin code
val activity = context as Activity
Can someone explain this to me or direct me to the appropriate documentation?
That's a very dangerous piece of code, and likely to be wrong most of the time. In Android every Activity is a Context, Activity is a child class of Context. The reverse is not true- not every context is an Activity. This code is assuming one is and is casting it. If they're wrong in that assumption, it will crash. While this is sometimes an ok thing to do, it is far more common to see it in beginner's code who don't understand exactly what a context is and make mistakes. Treat this as a code smell and be very cautious of code where you see this, it likely comes with an incomplete understanding of what they're doing.