Skip to content

Instantly share code, notes, and snippets.

@Sfshaza
Last active October 5, 2015 17:23
Show Gist options
  • Save Sfshaza/f046152d323ca12aadfa to your computer and use it in GitHub Desktop.
Save Sfshaza/f046152d323ca12aadfa to your computer and use it in GitHub Desktop.
optional_types_article
// 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