diff options
author | Justin Donaldson <jdonaldson@gmail.com> | 2013-08-20 21:25:34 -0700 |
---|---|---|
committer | Justin Donaldson <jdonaldson@gmail.com> | 2013-08-20 21:25:34 -0700 |
commit | 12bbb737f6417cb39a1f5ef3cf5d50f1bccc34a4 (patch) | |
tree | bf930910b67577281f0a9311b31201426d4ffbef /haxe.html.markdown | |
parent | 78133a784f65c32f5904f57b6d665167b026cd4f (diff) |
added ternary, some reformatting and fixes
Diffstat (limited to 'haxe.html.markdown')
-rw-r--r-- | haxe.html.markdown | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/haxe.html.markdown b/haxe.html.markdown index 90b2e250..e6c2b49c 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -29,8 +29,8 @@ references. /* A package declaration isn't necessary, but it's useful if you want to - organize your code into modules later on. Also worth mentioning, all - expressions in Haxe must end in a semicolon: + organize your code into modules later on. Also worth mentioning, if you use + more than one expression in a code block, it must end in a semicolon: */ package; // empty package, no namespace. @@ -252,6 +252,9 @@ class LearnHaxe3{ trace("also not printed."); } + // there is also a "ternary" if: + (j == 10) ? trace("equals 10") : trace("not equals 10"); + trace("Looping and Iteration"); // while loop @@ -310,13 +313,14 @@ class LearnHaxe3{ generalized algebraic data types in enums (more on enums later). Here's some basic value examples for now: */ - var my_dog_name = 'fido'; - var favorite_thing = ''; + var my_dog_name = "fido"; + var favorite_thing = ""; switch(my_dog_name){ - case "fido" : favorite_thing = 'bone'; - case "rex" : favorite_thing = 'shoe'; - case "spot" : favorite_thing = 'tennis ball'; - case _ : favorite_thing = 'some unknown treat'; + case "fido" : favorite_thing = "bone"; + case "rex" : favorite_thing = "shoe"; + case "spot" : favorite_thing = "tennis ball"; + default : favorite_thing = "some unknown treat"; + // case _ : "some unknown treat"; // same as default } // The "_" case above is a "wildcard" value // that will match anything. @@ -345,10 +349,10 @@ class LearnHaxe3{ trace("K equals ", k); // outputs 10 var other_favorite_thing = switch(my_dog_name) { - case "fido" : 'teddy'; - case "rex" : 'stick'; - case "spot" : 'football'; - case _ : 'some unknown treat'; + case "fido" : "teddy"; + case "rex" : "stick"; + case "spot" : "football"; + default : "some unknown treat"; } trace("My dog's name is" + my_dog_name |