当前位置: 首页>>代码示例 >>用法及示例精选 >>正文


Dart SplayTreeMap.forEach用法及代码示例


dart:collection 库中SplayTreeMap.forEach 方法的用法介绍如下。

用法:

void forEach(
   void f(
   K key,    
   V value   
)   
)
      override

action 应用于映射的每个键/值对。

调用 action 不得在映射中添加或删除键。

final planetsByMass = <num, String>{0.81: 'Venus', 1: 'Earth',
  0.11: 'Mars', 17.15: 'Neptune'};

planetsByMass.forEach((key, value) {
  print('$key: $value');
  // 0.81: Venus
  // 1: Earth
  // 0.11: Mars
  // 17.15: Neptune
});

相关用法


注:本文由纯净天空筛选整理自dart.dev大神的英文原创作品 forEach method。非经特殊声明,原始代码版权归原作者所有,本译文未经允许或授权,请勿转载或复制。