Should A. be preferred over B. for some reason? A....
# compiler
p
Should A. be preferred over B. for some reason? A.
open fun x() = Unit
B.
open fun x() { }
🅰️ 7
🅱️ 4
f
I guess this is a question of taste. I prefer A. because B. looks like somebody forgot to implement things, unless they do:
Copy code
open fun x() {
    // Intentionally left blank.
}
plus one 3
👍 2
e
https://kotlinlang.org/docs/coding-conventions.html#unit-return-type
If a function returns Unit, the return type should be omitted:
```fun foo() { // ": Unit" is omitted here
}```
(more of a #codingconventions question than #compiler; kotlinc produces the same output either way)
1
👍 1
f
Agree regarding #codingconventions but the quote does not address the question, because in both forms the return type is omitted. 😉
👍 3