Kết xuấtvi

vào

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

Marks a mutable borrowed parameter.

Syntax: in <type> <name>

Category#

function

Examples#

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

Marks a mutable borrowed parameter.

# =============================================================================
# in — Marks a mutable borrowed parameter
# =============================================================================
#
# What this teaches:
#   • Marks a mutable borrowed parameter.
#   • Related keywords: ra, từ
#
# Common mistakes:
#   • Mode mismatch — passing a `ra` (read-only) value to an `vào` position, or using `vào` to mutate a parameter declared as `ra` (SEM057).
#
# See also: ra, từ
# =============================================================================

# in — value parameter passing mode
#
# GRAMMAR:
#   paramMode :← 'in' type
#
# EXPECTED OUTPUT:
#   Scalar stdout smoke (see body).
#
# BACKEND:
#   Cross-ref: hàm/in-ex.fab.
#

fn tổng(mut list<int> values) → int {
    return values.sum()
}

main {
    const _ xs ← [1, 2, 3]
    print tổng(xs)
}

Expected output:

6