0

how do I return to main in Kotlin?

I want to repeat the main function continuously

21st Apr 2021, 2:44 PM
anas elaymach
anas elaymach - avatar
3 Respuestas
+ 1
Technically you could invoke main from main, but that’s really bad form. Normally if you want to loop, you’ll use use a WHILE TRUE, then build in an EXIT whereever you want the code to exit. What you really want is to learn how to do while and for loops. You don’t want to invoke main from main.
21st Apr 2021, 5:42 PM
Jerry Hobby
Jerry Hobby - avatar
+ 8
Hello there! :) If you try to repeat the main function you'll probably get an error. I suggest you to create your own main function and to repeat it as your necessity. - you only need to call it more in the main; - you can costumize it; - it's easy to use. I made a little example :) https://code.sololearn.com/cKDGZbT1g407/?ref=app
21st Apr 2021, 3:52 PM
Matthew
Matthew - avatar
0
Jerry Hobby Exactly what I needed to know, thanks alot
22nd Apr 2021, 12:43 AM
anas elaymach
anas elaymach - avatar