Files
wren/test/constructor/new.wren
Bob Nystrom b979272305 Clean up text handling a bit:
- Rename IO.write -> IO.print.
- Make IO.write not print a newline.
- Support \u Unicode escapes in strings.
2014-01-05 12:27:12 -08:00

18 lines
387 B
Plaintext

class Foo {
new { IO.print("zero") }
new(a) { IO.print(a) }
new(a, b) { IO.print(a + b) }
toString { return "Foo" }
}
// Can overload by arity.
new Foo // expect: zero
new Foo("one") // expect: one
new Foo("one", "two") // expect: onetwo
// Returns the new instance.
var foo = new Foo // expect: zero
IO.print(foo is Foo) // expect: true
IO.print(foo.toString) // expect: Foo