length: int- Модуль
- Коллекции →
- Получатель
- Map<K, V>
- Минимальное число аргументов
- 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.
Получатель
Map<K, V>
Ограничения параметров
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 ()}
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
stdlib-removed-member at
main.tpz:3:22
Reject Map.isEmpty
Ссылкаfunction inspect(value: Map<string, int>) -> () {let result = value.isEmpty()return ()}
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
stdlib-removed-member at
main.tpz:2:22
Reject Set.isEmpty
Ссылкаfunction inspect(value: Set<int>) -> () {let result = value.isEmpty()return ()}
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
stdlib-removed-member at
main.tpz:2:22