int, float, bool, str, byte

int, float, bool, str, byte

Luma provides a small set of primitive value types that cover the most common needs in everyday programming. They are designed to be clear, predictable, and type-safe.

int

  • A whole number (positive, negative, or zero).
  • Backed by Go’s int type.
  • Commonly used for counters, indexes, and arithmetic without fractions.
count: int = 42
temperature: int = -5

float

  • A floating-point number with decimal precision.
  • Backed by Go’s float64.
  • Used when you need fractional values or calculations requiring division.
pi: float = 3.14159
price: float = 19.99

bool

  • A logical true/false value.
  • Supports operators &&, ||, and !.
  • Often used in conditions and control flow.
isActive: bool = true
isDone: bool = false

if isActive && !isDone {
    print("Still working…")
}

str

  • A sequence of Unicode characters.
  • Defined using double quotes "...".
  • Supports interpolation with ${…} to embed expressions.
name: str = "Luma"
greeting: str = "Hello, ${name}!"

Escape Sequences

Strings support the following escape sequences:

Escape Character
\n Newline
\t Tab
\r Carriage return
\" Double quote
\\ Backslash
line: str = "first\nsecond"       // two lines
path: str = "C:\\Users\\file.txt" // backslash
csv: str = "a\r\nb"              // Windows-style line ending

byte

  • A single 8-bit value (0–255).
  • Useful for binary data, ASCII characters, and low-level tasks.
  • an be written as numeric values or hexadecimal literals (0x..).

Quick Reference Table

Type Example Literals Description
int 42, -5, 0 Whole numbers (positive, negative, zero)
float 3.14, -0.5, 2.0 Floating-point numbers with decimals
str "Hello", "Hi ${x}" Strings of characters, supports interpolation
bool true, false A logical true/false value.
byte 65, 0x41 Single 8-bit values (0–255), good for raw data
Last updated on