mirror of
https://github.com/wren-lang/wren.git
synced 2026-01-12 14:48:40 +01:00
Inside a method, all local variable lookup stops at the method boundary. In other words, methods, do not close over outer local variables. If a name is not found inside a method and is lowercase, it's a method on this. If it's capitalized, it's a global variable.
19 lines
245 B
Plaintext
19 lines
245 B
Plaintext
var foo = "variable"
|
|
|
|
class Foo {
|
|
foo { "method" }
|
|
|
|
method {
|
|
IO.print(foo)
|
|
}
|
|
|
|
static foo { "class method" }
|
|
|
|
static classMethod {
|
|
IO.print(foo)
|
|
}
|
|
}
|
|
|
|
(new Foo).method // expect: method
|
|
Foo.classMethod // expect: class method
|