Skip to content

Instantly share code, notes, and snippets.

@susisu
Created April 23, 2016 15:31
Show Gist options
  • Save susisu/bb73ec934f3cb7afd43a7c6c811bbcb2 to your computer and use it in GitHub Desktop.
Save susisu/bb73ec934f3cb7afd43a7c6c811bbcb2 to your computer and use it in GitHub Desktop.
package {
import flash.display.Sprite;
import flash.text.TextField;
public class Main extends Sprite {
public function Main() {
var tf : TextField = new TextField();
this.addChild(tf);
var foo : Foo = new Foo("Alice", function (f : Function) : void {
tf.text = f(); // ok
});
}
}
}
class Foo {
public var name : String;
public function Foo(name : String, callback : Function) {
this.name = name;
callback(this.bar);
}
private function bar() : String {
return this.name;
}
}
"use strict";
class Foo {
constructor(name, callback) {
this.name = name;
callback(this.bar);
}
bar() {
return this.name;
}
}
let foo = new Foo("Alice", function (f) {
console.log(f()); // error
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment