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

Side by Side 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 unified diff | Download patch
OLDNEW
(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 {}
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698