From 1a9107e43d25bcf06cefc701dbf6784d33898b1a Mon Sep 17 00:00:00 2001 From: Simon Richardson Date: Mon, 19 Aug 2013 20:24:18 +0100 Subject: [PATCH] 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. --- haxe.html.markdown | 35 ++++++++++++++++++++++++++++++++--- 1 file 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 //////////////////////////////////////////////////////////////////