From 228cc6ec5ae0d20a94292c66cf43e44755d3758b Mon Sep 17 00:00:00 2001 From: Cameron Steele Date: Mon, 29 Dec 2014 15:00:12 -0800 Subject: typo in Haxe documentation --- haxe.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'haxe.html.markdown') diff --git a/haxe.html.markdown b/haxe.html.markdown index 6a868f09..8599de8d 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -484,7 +484,7 @@ class LearnHaxe3{ // we can read this variable trace(foo_instance.public_read + " is the value for foo_instance.public_read"); // but not write it - // foo_instance.public_write = 4; // this will throw an error if uncommented: + // foo_instance.public_read = 4; // this will throw an error if uncommented: // trace(foo_instance.public_write); // as will this. trace(foo_instance + " is the value for foo_instance"); // calls the toString method -- cgit v1.2.3 From f1159951711a45c6f52b78ec247634c18f7de0b5 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Tue, 24 Mar 2015 01:19:13 +0300 Subject: Use "haxe" highlighting instead of C# --- haxe.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'haxe.html.markdown') diff --git a/haxe.html.markdown b/haxe.html.markdown index 8599de8d..b8e6a265 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -11,7 +11,7 @@ Haxe author). Note that this guide is for Haxe version 3. Some of the guide may be applicable to older versions, but it is recommended to use other references. -```csharp +```haxe /* Welcome to Learn Haxe 3 in 15 minutes. http://www.haxe.org This is an executable tutorial. You can compile and run it using the haxe -- cgit v1.2.3 From 0e118934db0c6813482cee606ce15cec681a9ae0 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Tue, 24 Mar 2015 01:21:28 +0300 Subject: [haxe] some additions and fixes (closes #489) --- haxe.html.markdown | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) (limited to 'haxe.html.markdown') diff --git a/haxe.html.markdown b/haxe.html.markdown index b8e6a265..e57c46a8 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -3,6 +3,7 @@ language: haxe filename: LearnHaxe3.hx contributors: - ["Justin Donaldson", "https://github.com/jdonaldson/"] + - ["Dan Korostelev", "https://github.com/nadako/"] --- Haxe is a web-oriented language that provides platform support for C++, C#, @@ -34,16 +35,20 @@ references. /* This is your first actual haxe code coming up, it's declaring an empty package. A package isn't necessary, but it's useful if you want to create a - namespace for your code (e.g. org.module.ClassName). + namespace for your code (e.g. org.yourapp.ClassName). + + Omitting package declaration is the same as declaring empty package. */ package; // empty package, no namespace. /* - Packages define modules for your code. Each module (e.g. org.module) must - be lower case, and should exist as a folder structure containing the class. - Class (and type) names must be capitalized. E.g, the class "org.module.Foo" - should have the folder structure org/module/Foo.hx, as accessible from the - compiler's working directory or class path. + Packages are directories that contain modules. Each module is a .hx file + that contains types defined in a package. Package names (e.g. org.yourapp) + must be lower case while module names are capitalized. A module contain one + or more types whose names are also capitalized. + + E.g, the class "org.yourapp.Foo" should have the folder structure org/module/Foo.hx, + as accessible from the compiler's working directory or class path. If you import code from other files, it must be declared before the rest of the code. Haxe provides a lot of common default classes to get you started: @@ -53,6 +58,12 @@ import haxe.ds.ArraySort; // you can import many classes/modules at once with "*" import haxe.ds.*; +// you can import static fields +import Lambda.array; + +// you can also use "*" to import all static fields +import Math.*; + /* You can also import classes in a special way, enabling them to extend the functionality of other classes like a "mixin". More on 'using' later. @@ -172,7 +183,8 @@ class LearnHaxe3{ Regexes are also supported, but there's not enough space to go into much detail. */ - trace((~/foobar/.match('foo')) + " is the value for (~/foobar/.match('foo')))"); + var re = ~/foobar/; + trace(re.match('foo') + " is the value for (~/foobar/.match('foo')))"); /* Arrays are zero-indexed, dynamic, and mutable. Missing values are @@ -383,11 +395,7 @@ class LearnHaxe3{ */ // if statements - var k = if (true){ - 10; - } else { - 20; - } + var k = if (true) 10 else 20; trace("K equals ", k); // outputs 10 @@ -628,6 +636,7 @@ enum ComplexEnum{ ComplexEnumEnum(c:ComplexEnum); } // Note: The enum above can include *other* enums as well, including itself! +// Note: This is what called *Algebraic data type* in some other languages. class ComplexEnumTest{ public static function example(){ -- cgit v1.2.3 From 03398877482f08c017e6774665f2c3b6e206ed34 Mon Sep 17 00:00:00 2001 From: Dan Korostelev Date: Tue, 24 Mar 2015 12:37:49 +0300 Subject: [haxe] polishing --- haxe.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'haxe.html.markdown') diff --git a/haxe.html.markdown b/haxe.html.markdown index e57c46a8..c807d2d7 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -12,7 +12,7 @@ Haxe author). Note that this guide is for Haxe version 3. Some of the guide may be applicable to older versions, but it is recommended to use other references. -```haxe +```csharp /* Welcome to Learn Haxe 3 in 15 minutes. http://www.haxe.org This is an executable tutorial. You can compile and run it using the haxe @@ -37,7 +37,7 @@ references. package. A package isn't necessary, but it's useful if you want to create a namespace for your code (e.g. org.yourapp.ClassName). - Omitting package declaration is the same as declaring empty package. + Omitting package declaration is the same as declaring an empty package. */ package; // empty package, no namespace. @@ -636,7 +636,7 @@ enum ComplexEnum{ ComplexEnumEnum(c:ComplexEnum); } // Note: The enum above can include *other* enums as well, including itself! -// Note: This is what called *Algebraic data type* in some other languages. +// Note: This is what's called *Algebraic data type* in some other languages. class ComplexEnumTest{ public static function example(){ -- cgit v1.2.3 From f9032e0eca3c780870127c410edf5ec85db01560 Mon Sep 17 00:00:00 2001 From: sm4rk0 Date: Tue, 19 May 2015 18:17:35 +0200 Subject: Update haxe.html.markdown Correct the condition variable for "do statement always runs at least once" section --- haxe.html.markdown | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'haxe.html.markdown') diff --git a/haxe.html.markdown b/haxe.html.markdown index c807d2d7..9b84a435 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -323,7 +323,7 @@ class LearnHaxe3{ var l = 0; do{ trace("do statement always runs at least once"); - } while (i > 0); + } while (l > 0); // for loop /* -- cgit v1.2.3 From 982b98468467c7a85f790fdcea2ff8d425b173de Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Stankovi=C4=87?= Date: Wed, 20 May 2015 14:06:05 +0200 Subject: [haxe/en] Few cosmetic fixes * correct the array name in a for loop iterating on an index * add an assignment for "case _" in first switch example * fix case of variable name in trace for control statement returning as an expression * move some inline comments to a separate line above the statement to prevent text overflow --- haxe.html.markdown | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) (limited to 'haxe.html.markdown') diff --git a/haxe.html.markdown b/haxe.html.markdown index 9b84a435..bbe51c79 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -340,7 +340,7 @@ class LearnHaxe3{ // (more on ranges later as well) var n = ['foo', 'bar', 'baz']; for (val in 0...n.length){ - trace(val + " is the value for val (an index for m)"); + trace(val + " is the value for val (an index for n)"); } @@ -375,7 +375,7 @@ class LearnHaxe3{ case "rex" : favorite_thing = "shoe"; case "spot" : favorite_thing = "tennis ball"; default : favorite_thing = "some unknown treat"; - // case _ : "some unknown treat"; // same as default + // case _ : favorite_thing = "some unknown treat"; // same as default } // The "_" case above is a "wildcard" value // that will match anything. @@ -397,7 +397,7 @@ class LearnHaxe3{ // if statements var k = if (true) 10 else 20; - trace("K equals ", k); // outputs 10 + trace("k equals ", k); // outputs 10 var other_favorite_thing = switch(my_dog_name) { case "fido" : "teddy"; @@ -495,8 +495,10 @@ class LearnHaxe3{ // foo_instance.public_read = 4; // this will throw an error if uncommented: // trace(foo_instance.public_write); // as will this. - trace(foo_instance + " is the value for foo_instance"); // calls the toString method - trace(foo_instance.toString() + " is the value for foo_instance.toString()"); // same thing + // calls the toString method + trace(foo_instance + " is the value for foo_instance"); + // same thing + trace(foo_instance.toString() + " is the value for foo_instance.toString()"); /* @@ -524,8 +526,8 @@ class LearnHaxe3{ */ class FooClass extends BarClass implements BarInterface{ public var public_any:Int; // public variables are accessible anywhere - public var public_read (default,null): Int; // use this style to only enable public read - public var public_write (null, default): Int; // or public write + public var public_read (default, null): Int; // enable only public read + public var public_write (null, default): Int; // or only public write public var property (get, set): Int; // use this style to enable getters/setters // private variables are not available outside the class. @@ -534,9 +536,10 @@ class FooClass extends BarClass implements BarInterface{ // a public constructor public function new(arg:Int){ - super(); // call the constructor of the parent object, since we extended BarClass + // call the constructor of the parent object, since we extended BarClass + super(); - this.public_any= 0; + this.public_any = 0; this._private = arg; } -- cgit v1.2.3 From 5816b59be65d47e6377cdad4c72b89f683bd0632 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marko=20Stankovi=C4=87?= Date: Wed, 20 May 2015 14:29:05 +0200 Subject: [haxe/en] Adding colon after comments ...as per @vendethiel's advice --- haxe.html.markdown | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'haxe.html.markdown') diff --git a/haxe.html.markdown b/haxe.html.markdown index bbe51c79..ee214540 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -495,9 +495,9 @@ class LearnHaxe3{ // foo_instance.public_read = 4; // this will throw an error if uncommented: // trace(foo_instance.public_write); // as will this. - // calls the toString method + // calls the toString method: trace(foo_instance + " is the value for foo_instance"); - // same thing + // same thing: trace(foo_instance.toString() + " is the value for foo_instance.toString()"); @@ -536,7 +536,7 @@ class FooClass extends BarClass implements BarInterface{ // a public constructor public function new(arg:Int){ - // call the constructor of the parent object, since we extended BarClass + // call the constructor of the parent object, since we extended BarClass: super(); this.public_any = 0; -- cgit v1.2.3