https://kotlinlang.org logo
#announcements
Title
# announcements
c

christophsturm

06/22/2017, 11:59 AM
what is the return value of a method
fun error(field: String, value: String)
is it Nothing?
m

marstran

06/22/2017, 12:28 PM
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

karelpeeters

06/22/2017, 12:33 PM
Also note that having a return type of
Nothing
means that the function never actually returns, ie. it always throws an exception.
p

Paul Woitaschek

06/22/2017, 1:42 PM
It's actually quite smart
Copy code
fun loopieLoop() : Nothing {
    while (true) {
      println()
    }
  }