oday
10/14/2018, 11:16 AMAndreas Sinz
10/14/2018, 11:17 AModay
10/14/2018, 11:18 AM?
go?var myFun: () -> Unit? = {}
?Andreas Sinz
10/14/2018, 11:18 AM(() -> Unit)?
oday
10/14/2018, 11:18 AMAndreas Sinz
10/14/2018, 11:19 AMmyFun?.invoke()
oday
10/14/2018, 11:19 AMSiebelsTim
10/14/2018, 11:23 AM{}
for the null case might also be an option. I think it makes the code more readable in some situations.oday
10/14/2018, 11:25 AMAndreas Sinz
10/14/2018, 11:31 AMif(myFun != { }) myFun()
could work, but nothing prevents you from accidentally invoking it. if its nullable, the compiler enforces that you check it firstoday
10/14/2018, 11:32 AMSiebelsTim
10/14/2018, 1:22 PM