Kết xuấtvi

Translation status: Tiếng Việt reader-locale proof. Code fences render through the vi pipeline; prose is canonical Latin.

Assigns a value to a binding, field, or assignable expression.

Aliases: assignment, assign

Syntax: <place> ← <expression>

Category#

assignment

Examples#

radix/corpus/assignatio/assignatio.fab (canonical · operator-group)#

Assigns a value to a binding, field, or assignable expression.

# =============================================================================
# ← — Assigns a value to a binding, field, or assignable expression.
# =============================================================================
#
# What this teaches:
#   • Explicit assignment — `place ← expression` rebinds a mutable variable
#     to a new value
#   • Compound operations — arithmetic expressions like `x ← x + 5` replace
#     removed compound assignment glyphs
#   • Postfix increment — `⊕` and `⊖` provide unit increment/decrement as
#     standalone statements
#
# Common mistakes:
#   • using `=` instead of `←` for assignment — `=` is structural field initialization in records, `←` is value assignment
#
# See also: =, fixum, varia, ⊕, ⊖
# =============================================================================

# assignatio — simple explicit assignment
#
# <place> ← <expression>
#
# Compound assignment glyphs were removed. Use explicit assignment, or postfix
# ⊕ / ⊖ for unit increment/decrement (see incrementa/incrementa.fab).
#
# EXPECTED OUTPUT:
#   20
#   25
#   15
#   30
#   10
#   salve munde

main {
    var int x  10

    x  20
    # 20
    print x

    x  x + 5
    # 25
    print x

    x  x - 10
    # 15
    print x

    x  x * 2
    # 30
    print x

    x  x / 3
    # 10
    print x

    var string s  "salve"
    s  s + " munde"
    # salve munde
    print s
}

Expected output:

20
25
15
30
10
salve munde