CINXE.COM

Learn with Haxe - Community driven Haxe code snippets, examples and tutorials. - Haxe programming language cookbook

<!DOCTYPE html> <html lang="en" id="page"><head prefix="og: https://ogp.me/ns# fb: https://ogp.me/ns/fb# article: https://ogp.me/ns/article#"><meta charset="utf-8"/><meta name="viewport" content="width=device-width"/><title>Learn with Haxe - Community driven Haxe code snippets, examples and tutorials. - Haxe programming language cookbook</title><base href="."/> <link rel="stylesheet" type="text/css" href="https://haxe.org/css/bootstrap.min.css"/><link rel="stylesheet" type="text/css" href="css/styles.min.css"/><link rel="stylesheet" type="text/css" href="css/haxe-nav.min.css"/><link rel="stylesheet" type="text/css" href="css/fonts.min.css"/><link rel="icon" href="https://haxe.org/favicon.ico"/><link rel="canonical" href="https://code.haxe.org/index.html"/><link href="https://code.haxe.org/rss.xml" rel="alternate" type="application/atom+xml" title="RSS Feed Haxe Code Cookbook"/><meta name="description" content="The Haxe Code Cookbook is a central learning resource with Haxe code snippets, examples and tutorials."/> <meta name="twitter:creator" content="@haxe_org"/> <meta property="og:title" content="Learn with Haxe - Community driven Haxe code snippets, examples and tutorials. - Haxe programming language cookbook"/><meta property="og:description" content="The Haxe Code Cookbook is a central learning resource with Haxe code snippets, examples and tutorials."/><meta property="og:type" content="article"/><meta property="og:url" content="https://code.haxe.org/index.html"/><meta property="og:image" content="https://code.haxe.org/img/share.png"/><meta property="article:publisher" content="haxe.org"/><meta property="article:published_time" content="2016-03-22 01:01:01"/><meta property="article:modified_time" content="2021-02-18 01:01:01"/><meta property="article:section" content="technology"/><meta property="article:tag" content="travis,cppia,expression-macro,html,workers,enum,thread,functional programming,multi-threading,macro,validation,operator-overloading,math,hxcpp,cpp,modules,dead-code-elimination,abstract-type,type-parameter-constraint,process,pattern-matching,functional-programming,type-params,class,completion,io,array,static-extension,json,macro-function,iterator,adt,github,server,canvas,haxe4,type-parameter,pipe,building-fields,collections,build-macro,parsing,git,ereg,extern,operator,clojure,javascript,haxelib,data-structures,configuration,date,reflection,nodejs,arguments,dom,compiler,filesystem,build-function,conditional-compilation,binary,time,libraries,emscripten"/></head><body><script type="text/javascript">function startsWith(str, searchString){return str.substr(0, searchString.length) === searchString;}if (!startsWith(location.href, "https://code.haxe.org/")) {window.location.replace("https://code.haxe.org/index.html");}</script><nav class="section nav dark"><div class="navbar navbar-fixed-top navbar-inverse"><div class="navbar-inner"><button class="btn btn-navbar" data-target=".nav-collapse" data-toggle="collapse" type="button"><span class="icon-bar"></span> <span class="icon-bar"></span> <span class="icon-bar"></span></button> <a class="brand haxe-logo" href="https://haxe.org/"><img alt="Haxe" height="21" onerror="this.src=&#039;https://haxe.org/img/haxe-logo-horizontal-on-dark.png&#039;" src="https://haxe.org/img/haxe-logo-horizontal-on-dark.svg" width="107"/></a><a class="brand sub ide" href="./">CODE</a><div class="nav-collapse collapse"><ul class="nav"> <li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-book"></i> Browse <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="category/beginner/">Beginner <small class="category-count">(21)</small></a></li><li><a href="category/abstract-types/">Abstract types <small class="category-count">(8)</small></a></li><li><a href="category/compilation/">Compilation <small class="category-count">(2)</small></a></li><li><a href="category/data-structures/">Data structures <small class="category-count">(5)</small></a></li><li><a href="category/design-patterns/">Design patterns <small class="category-count">(5)</small></a></li><li><a href="category/functional-programming/">Functional Programming <small class="category-count">(2)</small></a></li><li><a href="category/javascript/">JavaScript <small class="category-count">(4)</small></a></li><li><a href="category/macros/">Macros <small class="category-count">(20)</small></a></li><li><a href="category/principles/">Principles <small class="category-count">(3)</small></a></li><li><a href="category/other/">Other <small class="category-count">(9)</small></a></li></ul></li><li class="dropdown"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="fa fa-tags"></i> Tags <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="tag/expression-macro.html" rel="tag"><i class="fa fa-tag"></i> expression macro <small class="category-count">(11)</small></a></li><li><a href="tag/abstract-type.html" rel="tag"><i class="fa fa-tag"></i> abstract type <small class="category-count">(9)</small></a></li><li><a href="tag/enum.html" rel="tag"><i class="fa fa-tag"></i> enum <small class="category-count">(8)</small></a></li><li><a href="tag/building-fields.html" rel="tag"><i class="fa fa-tag"></i> building fields <small class="category-count">(8)</small></a></li><li><a href="tag/build-macro.html" rel="tag"><i class="fa fa-tag"></i> build macro <small class="category-count">(7)</small></a></li><li><a href="tag/javascript.html" rel="tag"><i class="fa fa-tag"></i> javascript <small class="category-count">(6)</small></a></li><li><a href="tag/pattern-matching.html" rel="tag"><i class="fa fa-tag"></i> pattern matching <small class="category-count">(5)</small></a></li><li><a href="tag/data-structures.html" rel="tag"><i class="fa fa-tag"></i> data structures <small class="category-count">(5)</small></a></li><li><a href="tag/dead-code-elimination.html" rel="tag"><i class="fa fa-tag"></i> dead code elimination <small class="category-count">(4)</small></a></li><li><a href="tag/class.html" rel="tag"><i class="fa fa-tag"></i> class <small class="category-count">(4)</small></a></li><li><a href="tag/iterator.html" rel="tag"><i class="fa fa-tag"></i> iterator <small class="category-count">(4)</small></a></li><li><a href="tag/collections.html" rel="tag"><i class="fa fa-tag"></i> collections <small class="category-count">(4)</small></a></li><li><a href="tag/libraries.html" rel="tag"><i class="fa fa-tag"></i> libraries <small class="category-count">(4)</small></a></li><li><a href="tag/validation.html" rel="tag"><i class="fa fa-tag"></i> validation <small class="category-count">(3)</small></a></li><li><a href="tag/array.html" rel="tag"><i class="fa fa-tag"></i> array <small class="category-count">(3)</small></a></li><li><a href="tag/multi-threading.html" rel="tag"><i class="fa fa-tag"></i> multi threading <small class="category-count">(2)</small></a></li><li><a href="tag/macro.html" rel="tag"><i class="fa fa-tag"></i> macro <small class="category-count">(2)</small></a></li><li><a href="tag/math.html" rel="tag"><i class="fa fa-tag"></i> math <small class="category-count">(2)</small></a></li><li><a href="tag/type-params.html" rel="tag"><i class="fa fa-tag"></i> type params <small class="category-count">(2)</small></a></li><li><a href="tag/static-extension.html" rel="tag"><i class="fa fa-tag"></i> static extension <small class="category-count">(2)</small></a></li><li><a href="tag/json.html" rel="tag"><i class="fa fa-tag"></i> json <small class="category-count">(2)</small></a></li><li><a href="tag/server.html" rel="tag"><i class="fa fa-tag"></i> server <small class="category-count">(2)</small></a></li><li><a href="tag/pipe.html" rel="tag"><i class="fa fa-tag"></i> pipe <small class="category-count">(2)</small></a></li><li><a href="tag/git.html" rel="tag"><i class="fa fa-tag"></i> git <small class="category-count">(2)</small></a></li><li><a href="tag/ereg.html" rel="tag"><i class="fa fa-tag"></i> ereg <small class="category-count">(2)</small></a></li><li><a href="tag/reflection.html" rel="tag"><i class="fa fa-tag"></i> reflection <small class="category-count">(2)</small></a></li><li><a href="tag/arguments.html" rel="tag"><i class="fa fa-tag"></i> arguments <small class="category-count">(2)</small></a></li><li><a href="tag/compiler.html" rel="tag"><i class="fa fa-tag"></i> compiler <small class="category-count">(2)</small></a></li><li><a href="tag/filesystem.html" rel="tag"><i class="fa fa-tag"></i> filesystem <small class="category-count">(2)</small></a></li><li><a href="tag/conditional-compilation.html" rel="tag"><i class="fa fa-tag"></i> conditional compilation <small class="category-count">(2)</small></a></li></ul></li><li class="divider"></li> <li class="dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="https://haxe.org/documentation/">Learn Haxe <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="https://haxe.org/documentation/introduction/" rel="external nofollow noopener">Introduction</a></li><li><a href="https://haxe.org/manual/" rel="external nofollow noopener">Manual</a></li><li class="active"><a href="https://code.haxe.org" rel="external nofollow noopener">Code Cookbook</a></li><li><a href="https://api.haxe.org" rel="external nofollow noopener">API Documentation</a></li><li class="divider"></li><li><a href="https://haxe.org/videos/" rel="external nofollow noopener">Videos</a></li><li class="divider"></li><li><a href="https://try.haxe.org" rel="external nofollow noopener">Try Haxe online</a></li><li><a href="https://lib.haxe.org" rel="external nofollow noopener">Haxelib</a></li></ul></li><li class=" dropdown"><a class="dropdown-toggle" data-toggle="dropdown" href="#">Connect <b class="caret"></b></a><ul class="dropdown-menu"><li><a href="https://github.com/HaxeFoundation" rel="external nofollow noopener"><i class="fa fa-github"></i> GitHub</a></li><li><a href="https://github.com/HaxeFoundation/haxe/issues" rel="external nofollow noopener"><i class="fa fa-github"></i> Bug reports</a></li><li><a href="https://stackoverflow.com/questions/tagged/haxe" rel="external nofollow noopener"><i class="fa fa-stack-overflow"></i> Stack Overflow</a></li><li><a href="https://community.haxe.org/" rel="external nofollow noopener"><i class="fa fa-envelope-o"></i> Forums</a></li><li><a href="https://discordapp.com/invite/0uEuWH3spjck73Lo" rel="external nofollow"><i class="fa fa-comments-o"></i> Discord</a></li><li><a href="https://gitter.im/HaxeFoundation/haxe" rel="external nofollow"><i class="fa fa-comments-o"></i> Gitter</a></li><li><a href="https://haxe.org/blog"><i class="fa fa-rss"></i> Blog</a></li><li class="divider"></li><li><a href="https://www.facebook.com/haxe.org/" rel="external nofollow noopener"><i class="fa fa-facebook"></i> Facebook</a></li><li><a href="https://twitter.com/search?q=%23haxe" rel="external nofollow noopener"><i class="fa fa-twitter"></i> #haxe</a></li><li><a href="https://twitter.com/haxelang" rel="external nofollow noopener"><i class="fa fa-twitter"></i> @haxelang</a></li><li><a href="https://twitter.com/haxe_org" rel="external nofollow noopener"><i class="fa fa-twitter"></i> @haxe_org</a></li><li class="divider"></li><li><a href="https://haxe.org/foundation/contact.html" rel="external nofollow noopener">Contact</a></li></ul></li></ul></div></div></div></nav><div class="main-content"><header class="hero-unit"><div class="container"><h1>Haxe Code Cookbook</h1><h3 class="lead">Community driven <a href="https://haxe.org/">Haxe</a> code snippets, examples and tutorials.</h3></div></header><hr/><section class="category-section"><div class="container"><h3><i class="fa fa-book"></i> Start browsing..</h3><div><span><a href="category/beginner/" class="btn btn-large"><strong itemprop="name">Beginner</strong> <small class="category-count">(21)</small></a></span><span><a href="category/abstract-types/" class="btn btn-large"><strong itemprop="name">Abstract types</strong> <small class="category-count">(8)</small></a></span><span><a href="category/compilation/" class="btn btn-large"><strong itemprop="name">Compilation</strong> <small class="category-count">(2)</small></a></span><span><a href="category/data-structures/" class="btn btn-large"><strong itemprop="name">Data structures</strong> <small class="category-count">(5)</small></a></span><span><a href="category/design-patterns/" class="btn btn-large"><strong itemprop="name">Design patterns</strong> <small class="category-count">(5)</small></a></span><span><a href="category/functional-programming/" class="btn btn-large"><strong itemprop="name">Functional Programming</strong> <small class="category-count">(2)</small></a></span><span><a href="category/javascript/" class="btn btn-large"><strong itemprop="name">JavaScript</strong> <small class="category-count">(4)</small></a></span><span><a href="category/macros/" class="btn btn-large"><strong itemprop="name">Macros</strong> <small class="category-count">(20)</small></a></span><span><a href="category/principles/" class="btn btn-large"><strong itemprop="name">Principles</strong> <small class="category-count">(3)</small></a></span><span><a href="category/other/" class="btn btn-large"><strong itemprop="name">Other</strong> <small class="category-count">(9)</small></a></span></div><br/></div></section><hr/><section class="container"><div class="row"><div class="span4"><h1>Learn with Haxe</h1><p class="lead">There are many ways to learn Haxe. On this website you'll find a lot of resources you need to become a Haxe developer. <br/><br/>So why not start learning and join the community today? If you haven’t learned Haxe yet, the time is now.</p><hr/></div><div class="span8"><h3><a href="rss.xml"><i class="fa fa-rss"></i></a> Latest articles</h3><h4><small class="category-count">Apr 27, 2021</small> Macros <small class="category-count">/</small> <a href="category/macros/strictly-typed-json.html" class="list-group-item">Strictly Typed JSON</a></h4><p>It's possible read JSON files at compile time into strictly typed objects in Haxe.‥</p><a href="category/macros/strictly-typed-json.html" class="btn btn-small btn-default" title="Read Strictly Typed JSON"><i class="fa fa-book"></i> Read &raquo;</a><hr/><h4><small class="category-count">Mar 03, 2021</small> Abstract types <small class="category-count">/</small> <a href="category/abstract-types/pipe.html" class="list-group-item">Pipe using Abstract Operator Overloading</a></h4><p>The following example demonstrates how the pipe operator is used to clean up nested function calls with Abstract Operator Overloading.‥</p><a href="category/abstract-types/pipe.html" class="btn btn-small btn-default" title="Read Pipe using Abstract Operator Overloading"><i class="fa fa-book"></i> Read &raquo;</a><hr/><h4><small class="category-count">Jun 24, 2020</small> Beginner <small class="category-count">/</small> <a href="category/beginner/declare-classes-with-structinit.html" class="list-group-item">Declare classes using @:structInit</a></h4><p>As an alternative to the traditional way of instantiating classes using the new keyword - which is how it's done in most object oriented languages such as Java or C# - you can use the @:structInit metadata when you declare the class.‥</p><a href="category/beginner/declare-classes-with-structinit.html" class="btn btn-small btn-default" title="Read Declare classes using @:structInit"><i class="fa fa-book"></i> Read &raquo;</a><hr/><h4><small class="category-count">May 05, 2020</small> Design patterns <small class="category-count">/</small> <a href="category/design-patterns/method-chaining-fluent-interface.html" class="list-group-item">Method chaining / Fluent interface</a></h4><p>This is an example of the Method chaining design pattern in Haxe.‥</p><a href="category/design-patterns/method-chaining-fluent-interface.html" class="btn btn-small btn-default" title="Read Method chaining / Fluent interface"><i class="fa fa-book"></i> Read &raquo;</a></div></div><hr/><div class="row"><div class="span4"><h3><i class="fa fa-big fa-rocket"></i> The cross-platform development toolkit</h3><p>Haxe is a modern high-level strictly-typed programming language with a fast optimizing cross-compiler.</p><a href="https://haxe.org/download" class="btn btn-large"><i class="fa fa-download"></i> Download Haxe 4.2.0</a><br/><small><em>Released: 2021-02-09</em></small></div><div class="span4"><h3><i class="fa fa-big fa-gears"></i> Learning by example</h3><p>The Haxe Foundation facilitates the following code cookbook for the Haxe commmunity. Enjoy learning Haxe; It is great!</p><strong>More documentation:</strong><p><p><i class="fa fa-external-link"></i> <a href="https://haxe.org/documentation" rel="external">Haxe Documentation</a></p><p><i class="fa fa-external-link"></i> <a href="https://haxe.org/manual" rel="external">Haxe Manual</a></p><p><i class="fa fa-external-link"></i> <a href="https://api.haxe.org" rel="external">Haxe API documentation</a></p><p>You can try Haxe in the browser! <a href="https://try.haxe.org" rel="external">try.haxe.org</a></p></p></div><div class="span4"><h3><i class="fa fa-big fa-globe"></i> Contribution is easy</h3><p>The project is being developed on GitHub. Feel free to contribute code snippets, tutorials and how-to guides. </p><p><i class="fa fa-github"></i> <a href="https://github.com/HaxeFoundation/code-cookbook" rel="external noopener">Haxe Code Cookbook on Github</a></p><p><a class="github-button" href="https://github.com/HaxeFoundation/code-cookbook" data-icon="octicon-star" data-style="mega" data-count-href="/HaxeFoundation/code-cookbook/stargazers" data-count-api="/repos/HaxeFoundation/code-cookbook#stargazers_count" data-count-aria-label="# stargazers on GitHub" aria-label="Star HaxeFoundation/code-cookbook on GitHub">Star</a> &nbsp; <a class="github-button" href="https://github.com/HaxeFoundation/code-cookbook/fork" data-icon="octicon-repo-forked" data-style="mega" data-count-href="/HaxeFoundation/code-cookbook/network" data-count-api="/repos/HaxeFoundation/code-cookbook#forks_count" data-count-aria-label="# forks on GitHub" aria-label="Fork HaxeFoundation/code-cookbook on GitHub">Fork</a><script async="async" defer="defer" src="https://buttons.github.io/buttons.js"></script></p></div></div></section></div><footer class="section dark site-footer"><div class="container"><div class="copyright"><p>&copy;2021&nbsp;<a class="hf-link" href="https://haxe.org/foundation/" rel="external nofollow noopener" title="Haxe Foundation Website">Haxe Foundation</a> |&nbsp;<a href="https://github.com/HaxeFoundation/code-cookbook" title="Haxe Code Cookbook on GitHub" rel="external nofollow noopener">Code Cookbook on GitHub</a> </p><p class="last-modified">Last deploy: May 08, 2021</p></div></div></footer><link rel="stylesheet" type="text/css" href="css/font-awesome.css"/><script defer="defer" src="https://haxe.org/js/jquery.min.js"></script><script defer="defer" src="https://haxe.org/js/bootstrap.min.js"></script><script> (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o), m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m) })(window,document,'script','//www.google-analytics.com/analytics.js','ga'); ga('create', 'UA-74262827-2', 'auto'); ga('send', 'pageview');</script></body></html>

Pages: 1 2 3 4 5 6 7 8 9 10