From 8234e5317985c62a2e5e1f23aef350238f139492 Mon Sep 17 00:00:00 2001 From: Garrit Franke Date: Sat, 13 Feb 2021 12:55:32 +0100 Subject: [PATCH] docs: add boolean values --- docs/concepts/datatypes.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/docs/concepts/datatypes.md b/docs/concepts/datatypes.md index a3c1d19..6b12d4a 100644 --- a/docs/concepts/datatypes.md +++ b/docs/concepts/datatypes.md @@ -2,6 +2,19 @@ Sabre comes with some generic data types. +## The Boolean type + +As in most other programming languages, a Boolean type in Sabre has two possible values: `true` and `false`. Booleans are one byte in size. The Boolean type in Sabre is specified using `bool`. For example: + +``` +fn main() { + let t = true + let f: bool = false // with explicit type annotation +} +``` + +The main way to use Boolean values is through conditionals, such as an `if` expression. We’ll cover how `if` expressions work in the ["Control Flow"](introduction/control-flow.md) section. + ## The Integer type The `integer` datatype represents a 4 byte decimal number.