Created
April 23, 2016 15:31
-
-
Save susisu/bb73ec934f3cb7afd43a7c6c811bbcb2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"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