حالة
Translation status: العربية reader-locale proof. Term names and code fences follow the ar 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