About goto in Kotlin

i found that there is not “goto” in Kotlin.
Could you tell me why? Didn’t i find it?
i think I’ll use “goto” occasionally,maybe it doesn’t matter to others

i do it.but i find nothing

My Google link was for “goto is evil”. It doesn’t give you any information on goto in Kotlin but lots of discussions about why goto may be considered harmful.

When Roman Elizarov talks about structured concurrency he refers to this blog, which includes a great explanation of the problems with goto.

I don’t know exactly why the Kotlin team decided against goto but I assume it’s because it is generally considered inferior to other jump expressions in a high level language such as Kotlin.

1 Like

i see. but It’s not very convenient.
sometimes,i may use “goto”.
i think “goto” can be saved

1 Like

I think we learned as a humanity that goto is just wrong. It is a mistake we made at the beginning. It still probably makes sense in some low-level languages, but almost all modern and high-level languages decided to not include it: Kotlin, Swift, Java, Python, JavaScript, Rust, Dart and more (I may be wrong about some of them).

5 Likes

Yes, Goto is a very convenient statement from C and C++ days and this should be saved in Kotlin

What are the C++ days exactly?
C++ is an actively developed language, which you can use if you choose to.

Every tutorial/guide on C++ says not to use goto for anything however

Some might say that it’s convenient only to the incompetent…

1 Like

Notes on avoiding “go to” statements

http://bitsavers.informatik.uni-stuttgart.de/pdf/stanford/cs_techReports/STAN-CS-70-148_Notes_on_Avoiding_GO_TO_Statements_Jan1970.pdf

Old but gold

1 Like