Kết xuấtvi

nếukhôngthì

Translation status: Tiếng Việt reader-locale proof. Term names and code fences follow the vi pack; supporting prose may still be English.

Adds an else-if branch after a previous nếu branch.

Aliases: else if

Syntax: nếukhôngthì <condition> <block>

Category#

control-flow

Examples#

radix/corpus/si/sin.fab (canonical · keyword)#

Adds an else-if branch after a previous nếu branch.

# =============================================================================
# nếukhôngthì — Adds an else-if branch after a previous nếu branch.
# =============================================================================
#
# What this teaches:
#   • Else-if chains — `nếukhôngthì <condition> { body }` adds intermediate conditional
#     branches between `nếu` and `khác`
#   • First match wins: evaluation stops at the first `nếu` or `nếukhôngthì` whose
#     condition is `đúng`
#
# Common mistakes:
#   • TODO: forgetting that `nếukhôngthì` blocks are skipped once a preceding branch
#     matches
#
# See also: nếu, khác
# =============================================================================

# si-sin-secus (poetic if-else-if chain)
#
# nếu <cond> { }
# nếukhôngthì <cond> { }
# khác { }
#
# GRAMMAR:
#   ifStmt :← 'nếu' expr block ('nếukhôngthì' expr block)* ('khác' block)?
#
# EXPECTED OUTPUT:
#   Afternoon (hour=14 matches first nếukhôngthì branch).

main {
    const int hour ← 14
    if hour ≺ 6 {
        print "Late night"
    }
    elif hour ≺ 12 {
        print "Morning"
    }
    elif hour ≺ 18 {
        # 14 ≥ 12 and 14 < 18
        print "Afternoon"
    }
    elif hour ≺ 22 {
        print "Evening"
    }
    else {
        print "Night"
    }
}

Expected output:

Afternoon

radix/corpus/sin/sin.fab (canonical · keyword)#

Adds an else-if branch after a previous nếu branch.

# =============================================================================
# nếukhôngthì — Adds an else-if branch after a previous nếu branch.
# =============================================================================
#
# What this teaches:
#   • Standalone else-if — `nếukhôngthì` provides an intermediate conditional branch
#     evaluated only when the preceding `nếu` condition was `sai`
#   • Chains: `nếu { } nếukhôngthì { } khác { }` for multi-way branching
#
# Common mistakes:
#   • Writing `khác nếu` instead of the canonical `nếukhôngthì` for else-if branches.
#
# See also: nếu, khác
# =============================================================================

# nếukhôngthì — else-if branch
#
# GRAMMAR:
#   elseIfClause :← 'nếukhôngthì' expr block
#
# EXPECTED OUTPUT:
#   Scalar stdout smoke (see body).
#
# BACKEND:
#   Cross-ref: nếu/sin.fab.
#

main {
    const int score ← 85
    if score ≥ 90 {
        print "excellent"
    }
    elif score ≥ 80 {
        print "good"
    }
    else {
        print "needs work"
    }
}

Expected output:

good