I am learning how to use Kotlin by doing tests online here: https://pl.kotl.in/P-v2WU7SH My code I'm testing is:
fun main() {
}
fun test(a: Int): Int{
var c: Int = a*2
return c
}
var z: Int = 5
var k: Int = test(z)
println(k)
I have 2 questions:
- Why does
println(k)show me the error ("Expecting a top level declaration") and when I remove it I have no problem? - Why when I delete
fun main(){}and run my code it displays: "No main method found in project"?