當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Dart UnmodifiableSetView用法及代碼示例

dart:collection 庫中UnmodifiableSetView 類的用法介紹如下。

另一個 Set 的不可修改的 Set 視圖。

不得調用可能更改集合的方法,例如 addremove

final baseSet = <String>{'Mars', 'Mercury', 'Earth', 'Venus'};
final unmodifiableSetView = UnmodifiableSetView(baseSet);

// Remove an element from the original set.
baseSet.remove('Venus');
print(unmodifiableSetView); // {Mars, Mercury, Earth}

unmodifiableSetView.remove('Earth'); // Throws.

繼承

Object SetBase<E> UnmodifiableSetView

可用的擴展

EnumByName

注釋

@Since("2.12")

相關用法


注:本文由純淨天空篩選整理自dart.dev大神的英文原創作品 UnmodifiableSetView<E> class。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。