This file contains 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
class Main { | |
static function main() { | |
var a = getValue(); | |
} | |
static function getValue():Tuple<Bool,Int> { | |
return new Tuple(true, 10); | |
} | |
} |
This file contains 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 haxe.macro.Context; | |
import haxe.macro.Expr; | |
class EnumComparisonMacro { | |
static function build() { | |
// get ComplexType for the abstract we're building | |
var t = switch(Context.getLocalType()) { | |
case TInst(_.get() => {kind: KAbstractImpl(_.get() => ab)}, _): TPath({pack: ab.pack, name: ab.name}); | |
case _: throw false; | |
} |
This file contains 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
@:dce | |
@:genericBuild(EitherMacro.build()) | |
class Either<Rest> {} |
This file contains 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 StructHelper.make; | |
typedef A = { | |
a:Int, | |
b:String, | |
c:Float, | |
d:Bool, | |
e:Array<Int>, | |
f:{ | |
g:Array<Bool>, |
This file contains 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
/** | |
Хеширование строки | |
**/ | |
public static function hash(key:String):Int { | |
// простейший алгоритм djb2 | |
inline function cca(s:String, i:Int):Int { | |
// наиболее быстрое и небезопасное получение кода символа | |
#if js | |
return (untyped s).charCodeAt(i); |
This file contains 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
class Main { | |
static function main() { | |
var event:MapChangeEvent<Map<String,Int>>; | |
$type(event.key); // String | |
$type(event.value); // Int | |
} | |
} |
This file contains 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
@:remove | |
@:autoBuild(SkipSerializeMacro.build()) | |
interface ISkipSerialize {} |
This file contains 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 haxe.Constraints.Function; | |
@:pythonImport("flask", "Flask") | |
extern class Flask { | |
function new(module:String); | |
function run():Void; | |
function route<T:Function>(path:String):T->T; | |
} | |
class Main { |
This file contains 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
using Tools; | |
class Main { | |
static function main() { | |
var a = haxe.ds.Option.Some(42); | |
var s = a.extract(Some(v) => {value: v}); | |
trace(s); | |
} | |
} |
This file contains 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 haxe.macro.Expr; | |
import haxe.Constraints.Function; | |
#if macro | |
import haxe.macro.Context; | |
import haxe.macro.Type; | |
using haxe.macro.Tools; | |
#end | |
class DI { |