传入
Translation status: 简体中文 reader-locale proof. Term names and code fences follow the zh-Hans pack; supporting prose may still be English.
Marks a mutable borrowed parameter.
Syntax: in <type> <name>
Category#
function
Related#
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