From f6fe961e92c97837f0a3e54b8dd151bff831917a Mon Sep 17 00:00:00 2001 From: Dawn Rose <63545980+tastethedream@users.noreply.github.com> Date: Tue, 6 Dec 2022 07:57:13 +0000 Subject: [PATCH] Update ex5-1.md Code updated to reflect QC2 section 4.1 --- ch05/ex5-1.md | 32 +++++--------------------------- 1 file changed, 5 insertions(+), 27 deletions(-) diff --git a/ch05/ex5-1.md b/ch05/ex5-1.md index eb3a617..ab0d7db 100644 --- a/ch05/ex5-1.md +++ b/ch05/ex5-1.md @@ -4,33 +4,11 @@ ```dart void main() { - Map 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')}'); -} -```