Files
wren/test/constructor/new.wren
T

18 lines
387 B
Plaintext
Raw Normal View History

2013-11-29 15:21:36 -08:00
class Foo {
new { IO.write("zero") }
new(a) { IO.write(a) }
new(a, b) { IO.write(a + b) }
2013-11-29 15:21:36 -08:00
2013-12-04 07:43:50 -08:00
toString { return "Foo" }
2013-11-29 15:21:36 -08:00
}
// Can overload by arity.
new Foo // expect: zero
new Foo("one") // expect: one
new Foo("one", "two") // expect: onetwo
2013-11-29 15:21:36 -08:00
// Returns the new instance.
var foo = new Foo // expect: zero
IO.write(foo is Foo) // expect: true
IO.write(foo.toString) // expect: Foo