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

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

Issue 22528003: update examples on homepage (Closed) Base URL: https://github.com/dart-lang/dartlang.org.git@master
Patch Set: fix comment Created 7 years, 4 months 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/syntax.dart
diff --git a/src/tests/site/code/syntax.dart b/src/tests/site/code/syntax.dart
new file mode 100644
index 0000000000000000000000000000000000000000..4abdd7187162ae42e2c879e0414c8eed3c3dad47
--- /dev/null
+++ b/src/tests/site/code/syntax.dart
@@ -0,0 +1,23 @@
+import 'dart:html'; // Dart supports libraries.
+
+// Define functions either inside or outside of classes.
+startOrEndTest() {
+ // ...
+}
+
+class Rectangle implements Shape { // Declaring a class...
+ final num height, width; // ...with properties.
+ num get area => height * width; // A property implemented with a getter.
+ // Also: function shorthand syntax (=>).
+ Rectangle(this.height, this.width); // Compact constructor syntax.
+}
+
+// Every app has a main() function, where execution starts.
+main() {
+ // The cascade operator (..) saves you from repetitive typing.
+ query("#button")
+ ..text = "Run test"
+ ..onClick.listen(startOrEndTest);
sethladd 2013/08/08 19:00:32 can we connect this to the rectangle class? As thi
Kathy Walrath 2013/08/08 23:16:59 Any ideas for a good example that uses cascades? I
sethladd 2013/08/08 23:43:12 should createGoldenEllipse be a named constructor?
Kathy Walrath 2013/08/08 23:51:59 Actually, I played with a List<Shape> but wasn't s
+}
+
+class Shape {}

Powered by Google App Engine
This is Rietveld 408576698