From ac3221471f4c476e1ed769dc51f96c95743253dc Mon Sep 17 00:00:00 2001 From: Mark <67615357+Dummi26@users.noreply.github.com> Date: Thu, 18 May 2023 02:06:45 +0200 Subject: [PATCH] Create intro.md before we can add advanced examples, we need type inference: just because I declare a variable as `[]` doesn't mean I'll never write a value to it. --- docs/intro.md | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 docs/intro.md diff --git a/docs/intro.md b/docs/intro.md new file mode 100644 index 0000000..8069b4e --- /dev/null +++ b/docs/intro.md @@ -0,0 +1,62 @@ +# Hello, world! + +Welcome to mers! Start by creating a file for your mers code: + + println("Hello, world!") + +now run it: `mers ` (replace mers the location of the compiled executable if it's not in your PATH) + +# basic concepts + +## variables + + a = 15 + println("a: " + a.to_string()) + // clones the value + b = a + a = 25 + println("a: " + a.to_string()) + println("b: " + b.to_string()) + +## if statements + + // type: bool + condition = true + if condition { + println("yes") + } else { + println("no") + } + +### else-if statements + + number = 15 + if number == 10 { + println("ten") + } else if number == 15 { + println("fifteen") + } else { + println("another number") + } + +## switch statements + + condition = true + // type: string/int + val = if condition { + "some text" + } else { + 15 + } + // do different things depending on the type + switch! val { + string println("text: " + val) + int { + // we need to convert val to a string before we can use it here + println("number: " + val.to_string()) + } + } + +## match statements + +\[...]