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.
This commit is contained in:
Mark 2023-05-18 02:06:45 +02:00 committed by GitHub
parent 8bfe5acd06
commit ac3221471f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

62
docs/intro.md Normal file
View File

@ -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 <file>` (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
\[...]