With
interface Anint {
fun doStuff()
}
class AClass : Anint {
override fun doStuff() = print("hello")
}
class AnintManager {
//val l = listOf<Anint>
fun manage() { //for each Anint, doStuff() }
}
fun main(args: Array<String>) {
val a = AClass()
val b = AClass()
AnintManager().manage()
}
How can I do so that every time I instanciate a new object that implement "Anint", that object gets added to list in the "AnintManager"? It'll be cool if the code for achieving this is placed in the interface