OLD | NEW |
---|---|
(Empty) | |
1 import 'dart:html'; // Dart supports libraries. | |
2 | |
3 // Define functions either inside or outside of classes. | |
4 startOrEndTest() { | |
5 // ... | |
6 } | |
7 | |
8 class Rectangle implements Shape { // Declaring a class... | |
9 final num height, width; // ...with properties. | |
10 num get area => height * width; // A property implemented with a getter. | |
11 // Also: function shorthand syntax (=>). | |
12 Rectangle(this.height, this.width); // Compact constructor syntax. | |
13 } | |
14 | |
15 // Every app has a main() function, where execution starts. | |
16 main() { | |
17 // The cascade operator (..) saves you from repetitive typing. | |
18 query("#button") | |
19 ..text = "Run test" | |
20 ..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
| |
21 } | |
22 | |
23 class Shape {} | |
OLD | NEW |