arekolek
05/10/2021, 7:20 PMfun foo(bar: Bar) {
if (!bar.canFoo) {
<http://logger.info|logger.info>("No foo for this bar")
return
}
// Make foo with bar
}
2️⃣
fun foo(bar: Bar) {
if (!bar.canFoo) {
return <http://logger.info|logger.info>("No foo for this bar")
}
// Make foo with bar
}
Luke
05/10/2021, 7:27 PMShawn
05/10/2021, 7:59 PM!bar.canFoo
a lot, consider adding (or extending) a complementary bar.cannotFoo
or whatever the appropriate name would bearekolek
05/10/2021, 8:02 PMcanFoo
was completely contrived, the question is purely about the return
Unit
as a return type to model void functionsreturn somethingThatReturnsUnit()
because of thatLuke
05/10/2021, 8:06 PM