渲染zh-Hant

副本

Translation status: 繁體中文 reader-locale proof. Term names and code fences follow the zh-Hant pack; supporting prose may still be English.

Generic set collection type.

Aliases: set

Syntax: 副本<T>

Category#

collection

Examples#

radix/corpus/intrinseca/copia-fundamenta.fab (canonical · keyword)#

Generic set collection type.

# =============================================================================
# 副本 — Generic set collection type
# =============================================================================
#
# What this teaches:
#   • Generic set collection type.
#   • Related keywords: 列表, 表格, ∈
#
# Common mistakes:
#   • Using `副本<T>` without an explicit type — `空集` requires an explicit type annotation like `副本<整數>` (SEM014).
#
# See also: 列表, 表格, ∈
# =============================================================================

# 副本<T> basic intrinsics
#
# Compiler-owned 副本<T> methodi — adde, habet, dele, longitudo, 空集.
#
# GRAMMAR:
#   copia.add(x) | copia.has(x) | copia.delete(x)
#   copia.length() | copia.is_empty()
#
# 副本<T> is a set-like collection; 空集 with 副本<T> creates an empty set.
#
# EXPECTED OUTPUT:
#   Smoke asserts exit 0 only.
#
# BACKEND: Go e2e whitelist — 副本 method surface not yet lowered for Go.

main {
    var set<int> numeri ← empty
    numeri.add(1)
    numeri.add(2)
    numeri.add(3)
    const bool habetduo ← numeri.has(2)
    const bool remotus ← numeri.delete(3)
    const int longitudo ← numeri.length()
    const bool vacuaest ← numeri.is_empty()
    print habetduo, remotus, longitudo, vacuaest
}