what is the return value of a method ` fun error(f...
# announcements
c
what is the return value of a method
fun error(field: String, value: String)
is it Nothing?
m
christophsturm: If you follow it with a block, it is by default Unit. If you follow it with
=
, it will be inferred by the expression on the right hand side.
k
Also note that having a return type of
Nothing
means that the function never actually returns, ie. it always throws an exception.
p
It's actually quite smart
Copy code
fun loopieLoop() : Nothing {
    while (true) {
      println()
    }
  }