diff options
author | Simon Richardson <simon@ustwo.co.uk> | 2013-08-19 20:24:18 +0100 |
---|---|---|
committer | Simon Richardson <simon@ustwo.co.uk> | 2013-08-19 20:24:18 +0100 |
commit | 1a9107e43d25bcf06cefc701dbf6784d33898b1a (patch) | |
tree | 60abc22f1798b6ed2d825e208b6898535135d674 /haxe.html.markdown | |
parent | 343c20b4e8f2bd71ade87ed70ee63c39e82c5154 (diff) |
Update haxe.html.markdown
I think one of Haxes strong point is the fact that control structures are expressions as well. We should point this out.
Diffstat (limited to 'haxe.html.markdown')
-rw-r--r-- | haxe.html.markdown | 35 |
1 files changed, 32 insertions, 3 deletions
diff --git a/haxe.html.markdown b/haxe.html.markdown index 94b4ea82..0b3c614d 100644 --- a/haxe.html.markdown +++ b/haxe.html.markdown @@ -284,8 +284,7 @@ class LearnHaxe3{ trace(modified_n + " is the value for modified_n"); var filtered_and_modified_n [for (val in n) if (n != "foo") n += "!"]; trace(filtered_and_modified_n + " is the value for filtered_and_modified_n"); - - + ////////////////////////////////////////////////////////////////// // Switch Statements (Value Type) ////////////////////////////////////////////////////////////////// @@ -311,7 +310,37 @@ class LearnHaxe3{ trace("My dog's name is" + my_dog_name + ", and his favorite thing is a: " + favorite_thing); - + + ////////////////////////////////////////////////////////////////// + // Expression Statements + ////////////////////////////////////////////////////////////////// + trace("***EXPRESSION STATEMENTS***"); + + /* + Haxe control statements are very powerful because every statement + is also an expression, consider: + */ + + // if statements + var k = if (true){ + 10; + } else { + 20; + } + + 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'; + } + + trace("My dog's name is" + my_dog_name + + ", and his other favorite thing is a: " + + other_favorite_thing); + ////////////////////////////////////////////////////////////////// // Converting Value Types ////////////////////////////////////////////////////////////////// |