Skip to main content

Primitive Types

Morph provides four fundamental primitive types.


Type Overview

TypeDescriptionExample
intInteger numbers42, -7, 0
floatFloating-point numbers3.14, -0.5, 1.0
stringText strings"hello", "Morph"
boolBoolean valuestrue, false

Integer (int)

Whole numbers without a decimal point:

age is 25 as int;
count is 0; // inferred as int
negative is -100;

Float (float)

Numbers with a decimal point:

pi is 3.14159 as float;
ratio is 0.5; // inferred as float
temperature is -40.0;

String (string)

Text enclosed in double quotes:

name is "Alice" as string;
greeting is "Hello, Morph!";
empty is "";

String concatenation uses +:

full is "Hello, " + name + "!";
Print(full); // Hello, Alice!

Boolean (bool)

The values true and false:

active is true as bool;
visible is false;

if (active) {
Print("Active!");
}

Default Type Inference

When no as annotation is provided, the compiler infers the type:

ValueInferred Type
42int
3.14float
"text"string
true / falsebool

Next Steps