Top-level function 'main' not found in package


#1

I created this code in my Intellij IDEA IDE

fun cases(obj: Any) {
    when (obj) {
        1    -> print("One")
        "Hello"  -> print("Greeting")
            is Long    -> print("Long")
        !is String  -> print("Not a String")
        else   -> print("Unknown")
    }
}

I got this error :

Top-level function 'main' not found in package

WHY and HOW do I fix it?


#2

Declare a “main” function.

See “Simplest version” here: http://kotlinlang.org/