coroutine
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
ข้อมูลสรุป
ฟังก์ชัน
เอกสารอ้างอิงเกี่ยวกับ API
ฟังก์ชัน
close
create
finally
coroutine. finally(
พารามิเตอร์
callback:Variant |
ตัวอย่างโค้ด
Coroutine Finally
local function observe(co, label)
coroutine.finally(co, function(status, ...)
print(label, status, ...)
end)
end
local finishing = coroutine.create(function()
return "ผลลัพธ์"
end)
observe(finishing, "finishing") --> finishing finished result
coroutine.resume(finishing)
local failing = coroutine.create(function()
error("ระเบิด", 0)
end)
observe(failing, "failing") --> failing error boom
coroutine.resume(failing)
local cancelled = coroutine.create(function()
coroutine.yield()
end)
coroutine.resume(cancelled)
observe(cancelled, "cancelled") --> cancelled cancelled
coroutine.close(cancelled)resume
status
wrap