Can I use a lambda for null checking?

Can I use a lambda for null checking?


fun exampleFunction() : Int? = null val example = exampleFunction() ?: { }

I want to use a lambda like so to run more code in case where the value is null like so but I get an error saying:


Type mismatch. Required: Int Found: () → Unit

How do I do what I’m trying to do?

submitted by /u/SmushyTaco
[link] [comments]