mirror of
https://github.com/MorizzG/rlox.git
synced 2025-12-06 04:12:42 +00:00
19 lines
261 B
Lox
19 lines
261 B
Lox
|
|
class A {
|
||
|
|
method(arg) {
|
||
|
|
print "A.method(" + arg + ")";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
class B < A {
|
||
|
|
getClosure() {
|
||
|
|
return super.method;
|
||
|
|
}
|
||
|
|
|
||
|
|
method(arg) {
|
||
|
|
print "B.method(" + arg + ")";
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
|
||
|
|
var closure = B().getClosure();
|
||
|
|
closure("arg"); // expect: A.method(arg)
|