1interface Item 2 name: string 3 count: number 4 quality?: number 5end 6local function summary(items: Item[]): string 7 local total = 0 8 for _, item in ipairs(items) do 9 if item.count == 0 then continue end 10 total += item.count 11 end 12 return `{#items} stacks, {total} items` 13end 14 15local bag: Item[] = { 16 { name = "Linen Cloth", count = 20 }, 17 { name = "Copper Ore", count = 0 }, 18 { name = "Peacebloom", count = 7, quality = 1 }, 19} 20 21print(summary(bag)) 22print(bag[3].quality ?? 0) 23local wasShown = false
compiling main.wowlua…
checking main.wowlua…
Try summary("bag") on line 21 to see a type error, or switch checking to strict to get nil safety. All errors and warnings.
run (ctrl ↵) runs main.wowlua in the emulated client and shows what it prints
loading wowlua in your browser…basic checkingdev build · minify none0 errors0 warningstake the language tour →