Imprimer le contenu d'une variable
Bonjour,
je suis en train d'apprendre l'utilisation de Kotlin en effectuant des test en ligne ici : https://pl.kotl.in/P-v2WU7SH
Mon code que je teste est :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| /**
* You can edit, run, and share this code.
* play.kotlinlang.org
*/
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) |
j'ai 2 questions :
1- pourquoi println(k) m'affiche l'erreur (Expecting a top level declaration) alors quand je la retire je n'ai aucun problème ?
2- pourquoi quand je supprime fun main() {} et j'exécute mon code il m'affiche : No main method found in project