| [#165] | project: specification | priority: medium | category: missing feature | |
|---|---|---|---|---|
| submitter | assigned to | status | date submitted | |
| Erik | Martin | won't fix | 2003-09-30 15:24:19.0 | |
| subject | Extending a class in a auxillary constructor | |||
| code |
class A() {
val arr:Array[byte] = new Array(0);
def this(newArr:Array[byte]) = {
this(){override val arr = newArr;}
};
}
|
|||
| what happened | A.scala:4: '}' expected but '{' found.
this(){override val arr = newArr;
^
|
|||
| what expected | Are you not supposed to be allowed extend the class when calling the primary constructor? Like: def this ... = { this(...) { *Extension* }; ... } | |||
| [back to overview] | ||||
| Matthias edited on 2003-09-30 23:49:10.0 |
| Erik, in your example, the braces are not even balanced. Apart from that, this() is a constructor call and not a class template. |
| Erik edited on 2003-10-01 11:31:44.0 |
| Sorry about the braces... now they are balanced. So how are you supposed to write an auxillary constructor that initialises some value in a different way than the main constructor? |
| Martin edited on 2003-10-09 12:29:04.0 |
| You need to call the main constructor. If you have mutable variables, you can initialize them afterwards. |