กรณี
Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH pack; supporting prose may still be English.
Introduces a branch inside an เลือก or แยก statement.
Aliases: case
Syntax: กรณี <expression> <block>
Category#
control-flow
Related#
Examples#
radix/corpus/casu/casu.fab (canonical · keyword)#
Introduces a branch inside an เลือก or แยก statement.
# =============================================================================
# กรณี — Introduces a branch inside an เลือก or แยก statement.
# =============================================================================
#
# What this teaches:
# • Pattern matching arms — `กรณี <expression> <block>` defines a branch in
# an `เลือก` match expression
# • Default fallback — `อื่น` provides the catch-all branch when no
# `กรณี` pattern matches
#
# Common mistakes:
# • non-exhaustive match without a `อื่น` catchall — every `เลือก` or `แยก` must cover all possibilities or add a `อื่น` arm
#
# See also: เลือก, แยก
# =============================================================================
# กรณี — branch arm in เลือก or แยก
#
# GRAMMAR:
# casuClause :← 'กรณี' expr block
#
# EXPECTED OUTPUT:
# Scalar stdout smoke (see body).
#
# BACKEND:
# Cross-ref: เลือก/elige.fab, แยก/discerne.fab.
#
main {
const _ code ← 200
switch code {
case 200 {
print "ok"
}
default {
print "other"
}
}
}Expected output:
ok