Skip to content

Commit

Permalink
Merge pull request #19 from rosera/tastethedream-patch-17
Browse files Browse the repository at this point in the history
Update ex5-1.md
  • Loading branch information
rosera authored Dec 15, 2022
2 parents 3477d46 + f6fe961 commit 764feeb
Showing 1 changed file with 5 additions and 27 deletions.
32 changes: 5 additions & 27 deletions ch05/ex5-1.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,33 +4,11 @@

```dart
void main() {
Map<int, dynamic> movieInformation = {0: 'Star wars'};
// Add element to Map
movieInformation[1] = 'Empire Strikes Back';
movieInformation[2] = 'Return of the Jedi';
// Loop through Map
movieInformation.keys.forEach(
(k) => print('Key: $k, Value: ${movieInformation[k]}')
);
// Show the keys
print('Keys: ${movieInformation.keys}');
// Show the values
print('Values: ${movieInformation.values}');
List listMonths = ['January', 'February', 'March'];
listMonths.add('April');
listMonths.forEach(print);
}
```

// Remove element from map using the key
movieInformation.remove(0);

// Loop through Map
movieInformation.keys.forEach(
(k) => print('Key: $k, Value: ${movieInformation[k]}')
);

// Check if a key exists
print('Key 1 exists: ${movieInformation.containsKey(1)}');
print('Value Star Wars exists: ${movieInformation.containsValue('Star Wars')}');
}
```

0 comments on commit 764feeb

Please sign in to comment.