Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:collection
  3. MapBase<K,V>
  4. addEntries method
addEntries
description

addEntries method

voidaddEntries(
  1. Iterable<MapEntry<K,V>>newEntries
)
override

Adds all key/value pairs ofnewEntries to this map.

If a key ofnewEntries is already in this map,the corresponding value is overwritten.

The operation is equivalent to doingthis[entry.key] = entry.valuefor eachMapEntry of the iterable.

final planets = <int, String>{1: 'Mercury', 2: 'Venus',  3: 'Earth', 4: 'Mars'};final gasGiants = <int, String>{5: 'Jupiter', 6: 'Saturn'};final iceGiants = <int, String>{7: 'Uranus', 8: 'Neptune'};planets.addEntries(gasGiants.entries);planets.addEntries(iceGiants.entries);print(planets);// {1: Mercury, 2: Venus, 3: Earth, 4: Mars, 5: Jupiter, 6: Saturn,//  7: Uranus, 8: Neptune}

Implementation

void addEntries(Iterable<MapEntry<K, V>> newEntries) {  for (var entry in newEntries) {    this[entry.key] = entry.value;  }}
  1. Dart
  2. dart:collection
  3. MapBase<K,V>
  4. addEntries method
MapBase class

[8]ページ先頭

©2009-2025 Movatter.jp