Use more conventional syntax for constructors.
They are now invoked like "new Foo". Also, superclass constructors are now much less semantically and syntactically weird. Since the instance is created before any constructor is called, there's no point in time where the instance isn't there.
This commit is contained in:
@@ -2,4 +2,4 @@ class Foo {
|
||||
write { io.write(_field) }
|
||||
}
|
||||
|
||||
Foo.new.write // expect: null
|
||||
(new Foo).write // expect: null
|
||||
|
||||
@@ -15,7 +15,7 @@ class Foo {
|
||||
}
|
||||
}
|
||||
|
||||
var foo = Foo.new
|
||||
var foo = new Foo
|
||||
foo.set(1, 2, 3, 4, 5)
|
||||
foo.write
|
||||
// expect: 1
|
||||
|
||||
@@ -19,15 +19,15 @@ class Node {
|
||||
}
|
||||
}
|
||||
|
||||
var a = Node.new
|
||||
var a = new Node
|
||||
a.set(null, "a", null)
|
||||
var b = Node.new
|
||||
var b = new Node
|
||||
b.set(null, "b", null)
|
||||
var c = Node.new
|
||||
var c = new Node
|
||||
c.set(a, "c", b)
|
||||
a = null
|
||||
b = null
|
||||
var d = Node.new
|
||||
var d = new Node
|
||||
d.set(c, "d", null)
|
||||
c = null
|
||||
d.write
|
||||
|
||||
@@ -3,7 +3,7 @@ class Foo {
|
||||
init { _field = "value" } // ...before an assignment to it.
|
||||
}
|
||||
|
||||
var foo = Foo.new
|
||||
var foo = new Foo
|
||||
// But invoke them in the right order.
|
||||
foo.init
|
||||
foo.write // expect: value
|
||||
|
||||
Reference in New Issue
Block a user