forked from Mirror/wren
Blocks, functions, and methods now have the same code for handling their bodies. This means that single-line methods work like single-line functions: they return the result of their expression.
18 lines
380 B
Plaintext
18 lines
380 B
Plaintext
class Foo {
|
|
new { IO.print("zero") }
|
|
new(a) { IO.print(a) }
|
|
new(a, b) { IO.print(a + b) }
|
|
|
|
toString { "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
|