:one: ```fun foo(bar: Bar) { if (!bar.canFoo) { ...
# codingconventions
a
1️⃣
Copy code
fun foo(bar: Bar) {
  if (!bar.canFoo) {
    <http://logger.info|logger.info>("No foo for this bar")
    return
  }
  // Make foo with bar
}
2️⃣
Copy code
fun foo(bar: Bar) {
  if (!bar.canFoo) {
    return <http://logger.info|logger.info>("No foo for this bar")
  }
  // Make foo with bar
}
1️⃣ 12
2️⃣ 1
l
I know you really want to save a line, but it would be a line that doesn't make sense to me. The intention is unclear
👆 1
s
another thing to consider is that if you find yourself writing
!bar.canFoo
a lot, consider adding (or extending) a complementary
bar.cannotFoo
or whatever the appropriate name would be
a
actually this
canFoo
was completely contrived, the question is purely about the
return
It's not that I want to save a line
I was wondering about how Kotlin has
Unit
as a return type to model void functions
and if it makes sense to use
return somethingThatReturnsUnit()
because of that
l
I have yet to find an example that makes sense, but yes: if it makes sense then please propagate the Unit. I don't think it makes sense here. It might be arguable if you also return a log in the "else" part