การเรนเดอร์th-TH

ใน

Translation status: ภาษาไทย reader-locale proof. Term names and code fences follow the th-TH 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: จาก, ออก
#
# Common mistakes:
#   • Mode mismatch — passing a `จาก` (read-only) value to an `ใน` position, or using `ใน` to mutate a parameter declared as `จาก` (SEM057).
#
# See also: จาก, ออก
# =============================================================================

# in — value parameter passing mode
#
# GRAMMAR:
#   paramMode :← 'in' type
#
# EXPECTED OUTPUT:
#   Scalar stdout smoke (see body).
#
# BACKEND:
#   Cross-ref: ฟังก์ชัน/in-ex.fab.
#

fn ผลรวม(mut list<int> values) → int {
    return values.sum()
}

main {
    const _ xs ← [1, 2, 3]
    print ผลรวม(xs)
}

Expected output:

6