Skip to content

Boolean (data type)

Christoph Heine edited this page Mar 22, 2018 · 6 revisions

Boolean

Boolean values are one of the primitive data types supported by nyan. A boolean can only be one of two possible values: true or false.

Syntax

(Abstract)
decision : bool = true

Example

Unit():
    convertible : bool

Spearman(Unit):
    convertible = true

Ram(Unit):
    convertible = false

The boolean value convertible of the object Spearman has the value true, while the boolean convertible of the object Ram has the value false.

Operators

Logical AND '&='

Ram():
    convertible = false

Conformity<Ram>():
    convertible &= true

If both the given and the original value are true the resulting value will also be true, else the new value will be false.

Logical OR '|='

Ram():
    convertible = false

Conformity<Ram>():
    convertible |= true

If at least one of the two values is true - i.e. the given value, the original value or both -, the resulting value will be true. Only if both values are false, the new value will also be false.

Clone this wiki locally