maxmello
10/17/2022, 1:10 PMfun <T: Any?> a(b: (value: T) -> Unit) {
b(null)
}
why does this not work? Why does it say T is non-nullable, even though it uses Any? ? Can I make this work without changing the lambda param to value: T??ephemient
10/17/2022, 1:20 PMT : Any? includes T : Any. if you want to always allow null, you need T? (so changing the type of your lambda, yes)maxmello
10/17/2022, 1:24 PMSam
10/17/2022, 1:25 PMList<T>, but remember that list elements have out variance whereas function parameters have in variance. So a List<T> is a List<T?>, but a (T) -> Unit is not a (T?) -> Unit.