Daniel Ef
Daniel Ef

Reputation: 75

what's the difference between kotlin main functions

what's the difference between this two types of main function in kotlin

fun main(args: Array<String>) {
    print("Hello World!")
}

and

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

Upvotes: 0

Views: 89

Answers (2)

Mayank Kumar Chaudhari
Mayank Kumar Chaudhari

Reputation: 18538

The syntax with the args is used to pass the parameters to the module from command line interface or from outside program. If you don't need it, you can omit it.

If you are getting started with kotlin I strongly recommend you to look at kotlin official website.

Upvotes: 2

R&#243;bert Nagy
R&#243;bert Nagy

Reputation: 7622

With the first option you could pass arguments when running your program

Upvotes: 1

Related Questions