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.io.Path; | |
/** | |
ファイルパスです。 | |
`haxe.io.Path` と以下の点で異なります。 | |
- イミュータブルです。 | |
- 作成時点で正規化されます。 | |
- ディレクトリーや拡張子が未指定のときは空文字になります。 | |
**/ |
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.io.Path; | |
import sys.FileSystem; | |
function main() | |
printFileTree(getFileTree("cwd", "relPath")); // change arguments | |
typedef FileOrDir = {name:String, children:Array<FileOrDir>}; | |
function getFileTree(cwd:String, relPath:String):FileOrDir { | |
final path = Path.join([cwd, relPath]); |
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 * as chokidar from "chokidar"; | |
/** | |
* Creates a watcher. | |
* | |
* @param {object} options | |
* @param {string | readonly string[]} options.paths Paths or Glob patterns to watch. | |
* @param {(path: string) => void} options.onChange | |
* @param {() => void} [options.onExit] | |
*/ |
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() { | |
final instance: MyEnum = EC0; | |
trace(switch instance { | |
case EC0: "EC0"; | |
default: "other"; | |
}); | |
} | |
} |
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 extern inline function swap(a, b) | |
return new Int2(b, a); | |
static function main() { | |
final input_a = 1974; | |
final input_b = 777; | |
final output = swap(input_a, input_b); | |
trace(output.a); | |
trace(output.b); |
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
// Node v13.12.0 | |
const str = "abcde"; | |
const searchString = "c"; | |
const indices = [ | |
str.indexOf(searchString), // 2 | |
str.indexOf(searchString, null), // 2 | |
str.lastIndexOf(searchString), // 2 | |
str.lastIndexOf(searchString, null) // -1 |
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: UInt = -1; | |
Sys.println(a); // -1 | |
trace(a); // 4294967295 | |
} | |
} |
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
abstract MyInt(Int) from Int to Int { | |
@:op(A...B) static extern inline function iter(a: MyInt, b: MyInt): MyIntIterator | |
return new MyIntIterator(a, b); | |
public extern inline function toInt() | |
return this; | |
} | |
// @:access(IntIterator) | |
// @:forward(min, max, hasNext) |
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
@:generic // Without this it compiles fine | |
class GenericObject<T> { | |
final value: T; | |
public function new(v: T) | |
this.value = v; | |
} | |
abstract GenericAbstract<T>(GenericObject<T>) from GenericObject<T> { | |
public inline function new(data: GenericObject<T>) |
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
#if macro | |
import haxe.macro.Context; | |
import haxe.macro.Expr.Field; | |
using StringTools; | |
class Macro { | |
static macro function checkMeta():Null<Array<Field>> { | |
warnIfNotFound(":myMeta"); | |
return null; |
NewerOlder