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 {} |