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
| var circle = { x: 10, y: 10, radius: 10 }; | |
| var rect = { x: 20, y: 20, width: 100, height: 100 }; | |
| function move( objectWithXAndY: { x: Int, y: Int } ) | |
| { | |
| objectWithXAndY.x += 5; | |
| objectWithXAndY.y += 5; | |
| } | |
| // both calls will work |
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
| var circle: { x: Int, y: Int, radius: Int }; | |
| circle = {x: 10, y: 10, radius: 10}; |
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
| var circle = { x: 100, y: 100, radius: 50 } | |
| circle.x = 90; // will work fine | |
| circle.y = "100"; // error: String should be Int | |
| circle = { x: 90, y: 80, radius: 10 } // will work fine | |
| circle = "circle"; // error: String should be { y : Int, x : Int, radius : Int } |
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
| var circle = { x: 100, y: 100, radius: 50 }; | |
| type(circle); // returns { y : Int, x : Int, radius : Int } |
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 org.devboy; | |
| import haxe.macro.Type; | |
| import neko.Lib; | |
| import haxe.macro.Expr; | |
| import haxe.macro.Context; | |
| class Funk | |
| { | |
| @:macro public static function partial( expressions: Array<Expr> ): Expr |
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
| function multiply( x: Float, y: Float ): Float | |
| { | |
| return x * y; | |
| } | |
| // now we create a partial function, with a preset parameters | |
| var multiplyByTen = Funk.partial( multiply, 10 ); | |
| // now we can call multiplyByTen to multiply a number by ten |
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 org.devboy; | |
| import haxe.macro.Type; | |
| import neko.Lib; | |
| import haxe.macro.Expr; | |
| import haxe.macro.Context; | |
| class Funk | |
| { |
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
| 5.times( callback( trace, "Hello" ) ) //traces Hello 5 times |
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
| 5.times( callback( trace, "Hello" ) ) //traces Hello 5 times |
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
| import org.devboy.ArrayUtils; | |
| using org.devboy.ArrayUtils; | |
| type( ArrayUtils.delete_if ); // Array<T> -> (T -> Bool) -> Array<T> | |
| type( [].delete_if ); // (T -> Bool) -> Array<T> |