Skip to main content
Journey Uncommon Logo
JourneyUncommon
mediumKotlingenerics variance in outSingle-choice MCQ

Why does the use-site projection MutableList<out Number> reject add but allow get?

fun sumFirst(list: MutableList<out Number>): Double { val n = list.get(0) // allowed // list.add(1) // forbidden return n.toDouble() }