kenkousen
11/23/2018, 9:26 PM@Test
internal fun `numList is unmodifiable`() {
val mutable: MutableList<Int> = numList as MutableList
assertThrows<UnsupportedOperationException> { numList.add(42) }
}
but if I comment out the line with the assignment to mutable
— which I don’t even use — the test won’t compile. Btw, the numList
variable is just val numList = listOf(3, 1, 4, 1, 5, 9)
.