# Basics


`basics/main.xo`

```xo
const GREETING = "hello"

fn greet(name: Str) -> Str {
  "${GREETING}, ${name}"
}

fn sign(n: Int) -> Str {
  if n < 0 { "negative" } else if n == 0 { "zero" } else { "positive" }
}

fn main(os: Os) {
  let who = "Ada"
  var count = 0
  for i in 0..3 {
    count += i
  }
  os.stdio.println(greet(who))
  os.stdio.println("count = ${count}, sign = ${sign(count - 5)}")
}
```

Output:

```text
hello, Ada
count = 3, sign = negative
```



- `let` binds a value that never changes; `var` binds one that can. Mutating
  a `let` is a compile error, and so is a binding you never use.
- The last expression of a block is its value, so `greet` needs no `return`.
  `if` is an expression too.
- `"${expr}"` interpolates any value that implements `Display`.
- `main` receives the operating system as `os`. Printing goes through
  `os.stdio`; step 8 explains why.
- `0..3` is a half open range (0, 1, 2); `0..=3` includes 3.

