-
-
Save ciscoheat/e1b27e45b7c2fe09a42b to your computer and use it in GitHub Desktop.
Revisions
-
ciscoheat revised this gist
Jun 6, 2014 . 1 changed file with 8 additions and 8 deletions.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class LazyExample implements Lazy this.values = [3, 5, 1, 7]; } @lazy public var sum : Int = { var result = 0; for (value in values) result += value; @@ -28,15 +28,15 @@ class LazyExample implements Lazy this.values = [3, 5, 1, 7]; } private var _sum : Null<Int>; public var sum(get, default) : Int; public function get_sum() : Int { if (_sum != null) return _sum; var result = 0; for (value in values) result += value; return _sum = result; } } -
cambiata revised this gist
Jun 6, 2014 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class LazyExample implements Lazy } } // ...into this: class LazyExample implements Lazy { -
cambiata created this gist
Jun 6, 2014 .There are no files selected for viewing
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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,42 @@ // The following will be macromagically transformed... class LazyExample implements Lazy { var values:Array<Int>; public function new() { this.values = [3, 5, 1, 7]; } @lazy public function getSum():Int { var result = 0; for (value in values) result += value; return result; } } // into this: class LazyExample implements Lazy { var values:Array<Int>; public function new() { this.values = [3, 5, 1, 7]; } private var _sum:Null<Int>; public function getSum():Int { if (this._sum != null) return this._sum; var result = 0; for (value in values) result += value; this._sum = result; return result; } }