Goto

  • Goto is a keyword, and it can be very usefull but it can also cause undefined behaviour while executing when used wrong (crashes, memory corruption, etc)
  • in general it is recommened to use goto only to jump out of nested loops, when break just doesn’t do the trick. but for the sake of functionalty it can jump anywhere you desire to.
local str = "hello"
function unsafe_funcjump(){
        unsafe_label:
        str += " planet"


}
  • If the function were to exit here, it would return to the location of the calling line which, in this case is after start_the_fun()
function start_the_fun(){
        goto unsafe_label
}

start_the_fun()
print(str) // prints hello planet