mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-18 13:49:59 +01:00
Every statement that isn't a method definition gets compiled into a special "<body>" method in the class. Every constructor in the class implicitly calls that before executing. Since it's an instance method, it executes in the context of the class: it can write fields, access "this", etc.
10 lines
109 B
Plaintext
10 lines
109 B
Plaintext
class Foo {
|
|
construct new() {}
|
|
|
|
System.print(this)
|
|
|
|
def toString { "foo" }
|
|
}
|
|
|
|
Foo.new() // expect: foo
|