Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Warning(15,5) Kotlin: Parameter 'args' is never used

//This is simple Hello world example in Kotlin (using intellij IDEA)
class Main {
    fun main (args: Array<String>){
        println("sss")
    }
}

I expect to print the msg , instead getting the warning

Warning:(5, 15) Kotlin: Parameter 'args' is never used

like image 561
Prakash Shukla Avatar asked Jan 01 '23 16:01

Prakash Shukla


1 Answers

From Kotlin documentation.

...function called main with one argument called args of the type "array of strings". args will contain the command-line arguments that the program is invoked with...

Also

it can be omitted if your program does not need to accept command-line arguments and you are using Kotlin 1.3:

fun main() {
println("Hello World!")
}

TLDR; If you don't use command-line and your Kotlin version is >= 1.3, you can remove args

like image 178
Taseer Ahmad Avatar answered Jan 04 '23 16:01

Taseer Ahmad