ที่เหลือ
Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.
Collects remaining parameters, operands, or extracted fields.
Aliases: rest
Syntax: ที่เหลือ <type> <name>
Category#
function
Related#
Examples#
radix/corpus/ceteri/ceteri.fab (canonical · keyword)#
Collects remaining parameters, operands, or extracted fields.
# =============================================================================
# ที่เหลือ — Collects remaining parameters, operands, or extracted fields.
# =============================================================================
#
# What this teaches:
# • Rest parameters — `ที่เหลือ <type> <name>` in a function signature collects
# all remaining arguments into a list
# • Variadic functions — `ที่เหลือ รายการ<จํานวน> numeri` enables summing an
# arbitrary number of numeric arguments
#
# Common mistakes:
# • confusing `ที่เหลือ` (rest parameter collecting remaining args into a list) with `เซตว่าง` (an empty collection initializer)
#
# See also: ฟังก์ชัน, ตัวถูกดำเนินการ, ออก
# =============================================================================
# ที่เหลือ — rest parameter (collects remaining arguments)
#
# ฟังก์ชัน <ชื่อ>(ที่เหลือ <ชนิดนามแฝง> <ชื่อ>) → <ชนิดนามแฝง>
#
# GRAMMAR:
# param :← 'ที่เหลือ' type ident
#
# EXPECTED OUTPUT:
# none
fn ผลรวม(rest list<int> numeri) → int {
var _ total ← 0
for from numeri const n {
total ← total + n
}
return total
}
main {
# ที่เหลือ receives the whole รายการ
print ผลรวม([1, 2, 3, 4])
}Expected output:
10