fun calc(x: List?): Int { // x should be non-null in arguments list x?.subList(x.size - 1, x.size) // but not also here! return x.size }