Limit of one fun main(arg : Array<String>) per package namespace


Is there a way to have a runnable fun declared in separate files within the sname package namespace?

If I create two files with fun main(…){} I get an error for each main()
Kotlin: kotlinExamples is already defined in ‘internal fun main(args : jet.Array<jet.String>) : Unit defined in kotlinExamples’




You can't have two mains in the same package. But you can have as many packages as you like in the same directory, so simply changing the name of the package in one of your files should fix the problem.



Interesting that packages are not tied to folders. thanks for the reply.