diff options
author | Martin Odersky <odersky@gmail.com> | 2005-10-05 11:08:17 +0000 |
---|---|---|
committer | Martin Odersky <odersky@gmail.com> | 2005-10-05 11:08:17 +0000 |
commit | 0a6b2c44cbdcea9e9c248b6a5b9970ad4cd86001 (patch) | |
tree | c008a12ea7e928b3f34e0c345c84832d90c1c8ad /test-nsc/files/run/constructors.scala | |
parent | 041a971eb7f89d2976bee5512a6caf7de7bff27c (diff) | |
download | scala-0a6b2c44cbdcea9e9c248b6a5b9970ad4cd86001.tar.gz scala-0a6b2c44cbdcea9e9c248b6a5b9970ad4cd86001.tar.bz2 scala-0a6b2c44cbdcea9e9c248b6a5b9970ad4cd86001.zip |
*** empty log message ***
Diffstat (limited to 'test-nsc/files/run/constructors.scala')
-rwxr-xr-x | test-nsc/files/run/constructors.scala | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test-nsc/files/run/constructors.scala b/test-nsc/files/run/constructors.scala new file mode 100755 index 0000000000..e85f3b8667 --- /dev/null +++ b/test-nsc/files/run/constructors.scala @@ -0,0 +1,29 @@ +// $Id$ + +// Test constructors, including multiple ones. + +class A(x: Int, y: Int) { + def this(x: Int) = this(x, x); + def this() = this(1); + override def toString() = "x=" + x + " y=" + y; + class B(a: Int, b: Int, c: String) { + def this(str: String) = this(x, y, str); + override def toString() = + "x=" + x + " y=" + y + " a=" + a + " b=" + b + " c=" + c; + } +} + +object Test { + def main(args: Array[String]): Unit = { + val a1 = new A(1,2); + val a2 = new A(3); + val a3 = new A(); + val b1 = new a1.B(1,2,"a"); + val b2 = new a2.B("b"); + Console.println(a1); + Console.println(a2); + Console.println(a3); + Console.println(b1); + Console.println(b2); + } +} |