Title here
Summary here
Nim has various value types including strings, integers, floats, booleans, etc. Here are a few basic examples.
import strformat
# Strings, which can be added together with `&`.
echo "nim" & "lang"
# Integers and floats.
echo fmt"1+1 = {1+1}"
echo fmt"7.0/3.0 = {7.0/3.0}"
# Booleans, with boolean operators as you'd expect.
echo true and false
echo true or false
echo not trueTo run the program, save it as values.nim and use the Nim compiler:
$ nim c -r values.nim
nimlang
1+1 = 2
7.0/3.0 = 2.3333333333333335
false
true
falseIn this Nim code:
strformat module to format strings, which is similar to Go’s fmt package.& operator instead of +.echo for printing to the console, which is similar to Go’s fmt.Println.and, or, and not, instead of &&, ||, and ! in Go.# for single-line comments instead of //.The output is identical to the original example, demonstrating that Nim handles these basic value types in a similar manner to other programming languages.