untuk (for)
Description / Deskripsi
Section titled “Description / Deskripsi”The untuk keyword starts a numeric for loop in SamaLang.
It is equivalent to for in standard Lua.
Keyword untuk digunakan untuk memulai perulangan for numerik dalam SamaLang.
Setara dengan for di Lua.
Usage / Penggunaan
Section titled “Usage / Penggunaan”untuk variable = start, stop, step boat -- codejure_moThe step is optional and defaults to 1.
Examples
Section titled “Examples”Count Up
Section titled “Count Up”untuk i = 1, 5 boat tulis(i)jure_mo-- Output: 1, 2, 3, 4, 5Count Down
Section titled “Count Down”untuk i = 5, 1, -1 boat tulis(i)jure_mo-- Output: 5, 4, 3, 2, 1Step by 2
Section titled “Step by 2”untuk i = 0, 10, 2 boat tulis(i)jure_mo-- Output: 0, 2, 4, 6, 8, 10Iterate Over Array
Section titled “Iterate Over Array”ada buah = {"apel", "mangga", "jeruk", "pisang"}
untuk i = 1, #buah boat tulis(tostring(i) .. ". " .. buah[i])jure_mo-- Output:-- 1. apel-- 2. mangga-- 3. jeruk-- 4. pisangLoop with Variable Scope
Section titled “Loop with Variable Scope”untuk i = 1, 3 boat ada nama = "Item " .. tostring(i) tulis(nama)jure_mo-- i is not accessible here