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
class Test { | |
static function main(){ | |
stringOrInt( "hello" ); | |
stringOrInt( 10 ); | |
} | |
static function stringOrInt( either:AcceptEither<String,Int> ) { | |
switch either.type { | |
case Left(str): trace("string: "+str); | |
case Right(int): trace("int: "+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
// Compile with `haxe -js AbstractExample.js -dce full -main AbstractExample.hx` | |
import js.html.AnchorElement; | |
class AbstractExample { | |
static function main() { | |
var myAnchor = new MyAnchor( "http://google.com", "Click here!" ); | |
expectsAnchor( myAnchor ); // Notice how it automatically casts back down to AnchorElement | |
} |
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 haxe.PosInfos; | |
class TraceMemberMethod | |
{ | |
static function main() new TraceMemberMethod(); | |
public function new() { | |
messages = []; | |
trace( "hey" ); // Uses haxe.Log.trace() |
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
class Module1 | |
{ | |
static function main() { | |
SharedCode.greet("Jason"); | |
} | |
} |
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 sys.db; | |
@:coreApi class Mysql { | |
static var init = false; | |
/** | |
Opens a new MySQL connection on the specified path. | |
Note that you will need a MySQL JDBC driver. | |
"socket" option currently not supported |
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
class Cast | |
{ | |
static function main() | |
{ | |
var array = [0,1,2,3]; | |
var list = Lambda.list( array ); | |
var map = [ "a"=>0, "b"=>1, "c"=>2 ]; | |
var stringMap:haxe.ds.StringMap<Int> = map; | |
var myAbstract:AbstractIterator<Int> = array; | |
var myAbstract2:AbstractIterator2<Int> = array; |
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
class ArrayAccessTest { | |
static function main() { | |
var myArray:MyArray<Int> = [0,10,20]; | |
trace ( myArray[1] ); | |
trace ( myArray["one"] ); | |
trace ( myArray[["one","two","three"]] ); | |
} | |
} | |
abstract MyArray<T>(Array<T>) from Array<T> to Array<T> { |
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 haxe.macro.Expr; | |
import haxe.macro.Context; | |
import neko.Lib; | |
class BuildInMacroTests { | |
public static function main() { | |
var s:MyModel = new MyModel(); | |
Formatter.__Output_Formatter( s ); | |
} | |
} |
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 haxe.macro.Expr; | |
import haxe.macro.Type; | |
import haxe.macro.Context; | |
class MacroTest | |
{ | |
macro public function build():Array<Field> | |
{ | |
trace ("Build macro"); |
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 haxe.macro.Expr; | |
import haxe.macro.Context; | |
import sys.FileSystem; | |
import sys.io.File; | |
import haxe.io.Path; | |
class BuildMacro | |
{ | |
static function build() | |
{ |