// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) class MyList(val del: MutableList) : MutableList by del { var addCount = 0 override fun add(o: E): Boolean { addCount++ return del.add(o) } override fun addAll(c: Collection): Boolean { addCount += c.size return del.addAll(c) } } fun main() { val lst = MyList(ArrayList()) lst.addAll(listOf(1, 2, 3)); for(v in lst) { println(v); } println(lst.addCount); }