Last active
October 5, 2015 17:23
-
-
Save Sfshaza/f046152d323ca12aadfa to your computer and use it in GitHub Desktop.
optional_types_article
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This example, part of the | |
// https://www.dartlang.org/articles/optional-types | |
// article, demonstrates a static warning in Dart. | |
class Point { | |
final num x, y; | |
Point(this.x, this.y); | |
Point operator +(Point other) { | |
return new Point(x + other.x, y + other.y); | |
} | |
String toString() { | |
return "x: $x, y: $y"; | |
} | |
} | |
main() { | |
Point p1 = new Point(0, 0); | |
Point p2 = new Point(10, 10); | |
int n = p1 + p2; | |
print(n); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment