lalo (goto)
Description / Deskripsi
Section titled “Description / Deskripsi”The lalo keyword is the goto statement in SamaLang. It performs an unconditional jump to a label.
It is equivalent to goto in standard Lua.
Keyword lalo adalah pernyataan goto dalam SamaLang. Melakukan lompatan tak bersyarat ke label.
Setara dengan goto di Lua.
Usage / Penggunaan
Section titled “Usage / Penggunaan”lalo label_name-- ...::label_name::Examples
Section titled “Examples”Skip Code
Section titled “Skip Code”untuk i = 1, 5 boat lalo i == 3 tres lalo skip jure_mo tulis("Proses: " .. tostring(i)) ::skip::jure_mo-- Output:-- Proses: 1-- Proses: 2-- Proses: 4-- Proses: 5Exit Loop Early
Section titled “Exit Loop Early”ada i = 0
ulang i = i + 1 lalo i == 3 tres lalo selesai jure_mo tulis("Iterasi: " .. tostring(i)) ::selesai::sampe i > 5
tulis("Selesai di iterasi " .. tostring(i))-- Output:-- Iterasi: 1-- Iterasi: 2-- Selesai di iterasi 3Error Handling Pattern
Section titled “Error Handling Pattern”fungsi bagi(a, b) lalo b == 0 tres tulis("Error: Bagi dengan nol!") semalik nda_isi jure_mo ::lanjut:: semalik a / bjure_mo
tulis(bagi(10, 2)) -- Output: 5tulis(bagi(10, 0)) -- Output: Error: Bagi dengan nol!