How to create an instance of an abstract class in Kotlin?
Hi everyone! I just started learning Kotlin after Java and encountered an unclear situation. In Java, you cannot directly create an object of an abstract class — you need to inherit and implement abstract methods. But in Kotlin, I see that sometimes you can write something like:
```kotlin
abstract class MyAbstractClass {
abstract fun doSomething()
}
fun main() {
// Does this work in Kotlin?
val instance = object : MyAbstractClass() {
override fun doSomething() {
println("Implementation")
}
}
}
```
I have an abstract class `Shape` with an abstract method `calculateArea()`. I need to create a temporary object for testing without creating a separate subclass. Is this possible? And if so, how does it work under the hood? I've heard about