Kotlin Native equivalent of System.exit(-1)

Nate Vaughan :

In the following Kotlin/JVM program System.exit(-1) stops the execution of the program with an error exit code:

fun main(args: Array<String>) {
    if (args.size < 2) {
        println("too few args!")
        System.exit(-1)
    }
    println("Hello, ${args[1]} from ${args[0]}")
}

Kotlin/Native does not have access to any Java classes, including System. So what would the equivalent function be for a Kotlin/Native program to stop execution of the program with an error code?

Zoe :

Use exitProcess:

import kotlin.system.exitProcess
...
exitProcess(exitCode)

Declaration and documentation in the Kotlin source code.

Guess you like

Origin http://10.200.1.11:23101/article/api/json?id=459632&siteId=1