length: int- 모듈
- 컬렉션 →
- 수신자
- Set<T>
- 최소 인자 수
- 0
- 최대 인자 수
- 0
Declaration and parameters
링크사용 조건
기본 포함 · 예
These types are provided by the language. No module import is required.
The declarations below describe the standard operations on built-in values.
수신자
Set<T>
매개변수 제약
Test whether a Bytes, Map, or Set value is empty by comparing its length property with zero. The comparison is true exactly when the collection has no bytes, entries, or elements.
Bytes, Map, and Set do not expose an isEmpty member. Read the length property and use the ordinary equality operator.
관련 규칙 · Test collection emptiness with length →결과
The declared result type is int.
효과
실패
Result and effects
링크Select this field from a value of its named type without call parentheses.
Runtime behavior, boundary inputs, effects, and failures remain Pending until their source contracts and public CLI observations are reviewed.
Related entries
링크Test collection emptiness with length
링크Test collection emptiness with length
Test whether a Bytes, Map, or Set value is empty by comparing its length property with zero. The comparison is true exactly when the collection has no bytes, entries, or elements.
Bytes, Map, and Set do not expose an isEmpty member. Read the length property and use the ordinary equality operator.
이유
A collection already exposes its count through length. Comparing that value with zero expresses emptiness for every collection without another query name or a type-specific method.
Test empty and nonempty maps with length
링크import std.iolet empty: Map<string, int> = map {}let filled = map { "one": 1 }io.writeLine("{empty.length == 0}:{filled.length == 0}")
true:false
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
true:false
Test empty and nonempty sets with length
링크import std.iolet empty: Set<int> = set {}let filled = set { 1 }io.writeLine("{empty.length == 0}:{filled.length == 0}")
true:false
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
true:false
Test empty and nonempty byte sequences with length
링크import std.bytes { Bytes }import std.testimport std.iolet empty = Bytes.empty()let filled = test.assertOk(Bytes.fromArray([1]))io.writeLine("{empty.length == 0}:{filled.length == 0}")
true:false
기대 결과
기대 결과
실행을 마칩니다. 종료 코드 0.
true:false
Reject Bytes.isEmpty
링크import std.bytes { Bytes }function inspect(value: Bytes) -> () {let result = value.isEmpty()return ()}
표준 출력 없음.기대 결과
Reject Map.isEmpty
링크function inspect(value: Map<string, int>) -> () {let result = value.isEmpty()return ()}
표준 출력 없음.기대 결과
Reject Set.isEmpty
링크function inspect(value: Set<int>) -> () {let result = value.isEmpty()return ()}
표준 출력 없음.