1

I'm attempting to make a simple program in order to play around with Dart. When attempting to extend Vec2 with Circle, I receive an error message stating that 'no such type' exist Vec2

I have a structure such that:

Inside geom/geom.dart

#library("geom");

#import("dart:math", prefix:'Math');

#source("Vec2.dart");
#source("Circle.dart");

With two simple classes

Inside geom/Vec2.dart

class Vec2 {
    num x;
    num y;
}

Inside geom/Circle.dart

class Circle extends Vec2 {
    num radius;
    Circle(this.radius) : super();
}

What is the correct way to subclass in Dart? Must the Classes both exist in the same file?

4

1 に答える 1

2

あなたのコードは動作します。エディター バージョン 0.1.0.201210010959、ビルド 13075、およびエディター バージョン バージョン 0.1.0.201210082015、ビルド 13393 でテストしたところです。それが必要な場合は、ファイルごとに 1 つのクラスを作成できます。(注: Dart はファイルごとに 1 つのクラスを必要としません。)

パスを再確認しましたか? バージョン番号とスクリーンショットを貼り付けてください。できれば、ディレクトリへのリンクを提供してください。

于 2012-10-08T22:21:06.787 に答える