Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1225)

Unified Diff: src/tests/site/code/collections.dart

Issue 83663005: added front page samples to testing, plus a couple of tweaks to front page and code lab (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: put front page code snippets under testing, minor tweaks, fixed carousel height problem Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/tests/site/code/collections.dart
diff --git a/src/tests/site/code/collections.dart b/src/tests/site/code/collections.dart
new file mode 100644
index 0000000000000000000000000000000000000000..caea9af33d75c538d614960fa3a31d35c640f1ef
--- /dev/null
+++ b/src/tests/site/code/collections.dart
@@ -0,0 +1,22 @@
+void main() {
+ Map famousDuos = { 'Han Solo': 'Chewbacca', // Map literal.
+ 'Bonnie': 'Clyde',
+ 'Laurel': 'Hardy' };
+ List myFriends = [ 'Seth', 'Kathy', 'Shailen' ]; // List literal.
+
+ // Create lists and maps from Iterable objects.
+ List shuffledSidekicks = new List.from(famousDuos.values)..shuffle();
+ Map mixedDuos = new Map.fromIterables(famousDuos.keys, shuffledSidekicks);
+
+ // Iteration.
+ mixedDuos.forEach((k, v) { print('$k, $v'); });
+
+ // Some lists, maps, and sets are growable.
+ Set setOfMyFriends = new Set.from(myFriends);
+ Set famousPeople = new Set.from(famousDuos.values);
+ famousPeople.addAll(famousDuos.keys);
+
+ // Rich set of functionality for collections.
+ print(famousPeople.intersection(setOfMyFriends).isEmpty);
+ print(famousPeople.union(setOfMyFriends).length);
+}

Powered by Google App Engine
This is Rietveld 408576698