t27.aiРусский

True, false and text

You will learn

How to declare a bool and a str, and what a test can compare them with.

A bool is true or false. A str is text in double quotes, and the text may hold characters that mean something elsewhere in t27, such as a semicolon or two slashes: inside quotes they are just text. A test compares a bool or a str with == and !=. One honest limit: the checker in this browser does not stop a str given to a u8 constant, so keep types and values matched yourself.

Try it

Change NAME in the lesson spec and fix the test so that it passes again.

Open the interactive lesson →

t27 basics 6: bool and str
t27 basics 6: bool and str ↗

The two non-number types of t27 in one table, with what a test can do with them. Lesson 6 of the t27 basics course.

specs/basics/06_true_false_and_text.t27

// SPDX-License-Identifier: Apache-2.0
; t27 basics, lesson 6: True, false and text.
; bool holds true or false; str holds text between double quotes.

module basics_06_true_false_and_text;

pub const READY : bool = true;
pub const DONE : bool = false;
pub const NAME : str = "trit";
pub const NOT_A_COMMENT : str = "; and // inside quotes are text";

test bools_and_text_compare {
    assert READY == true;
    assert READY != DONE;
    assert NAME == "trit";
}

Open the lesson's spec in the player ↗

All lessons