dryLang
docsplaygrounddownloadgithub

Getting Started

  • Home
  • Getting Started
  • Setup

Language Basics

  • Variables
  • Types
  • Operators
  • Comments
  • Strings

Control Flow

  • Control Flow
  • Loops

Advanced Concepts

  • Functions
  • Structs
  • Collections
  • Modules
  • HTTP Server
  • Database

Reference

  • Built-ins
  • Error Handling
  • Errors

Examples

  • Hello
  • Variables
  • Functions
  • Control Flow
  • Structs
  • Arrays Maps
  • Try Err
  • Imports
  • Math
  • Strings
  • Http Server
  • Database
  • File Io

Templates

  • Automation
  • Cli Tool
  • Crud
  • Fetch Json
  • File Server
  • Hello
  • Html Render
  • Rest Api
Docs Menu

Getting Started

  • Home
  • Getting Started
  • Setup

Language Basics

  • Variables
  • Types
  • Operators
  • Comments
  • Strings

Control Flow

  • Control Flow
  • Loops

Advanced Concepts

  • Functions
  • Structs
  • Collections
  • Modules
  • HTTP Server
  • Database

Reference

  • Built-ins
  • Error Handling
  • Errors

Examples

  • Hello
  • Variables
  • Functions
  • Control Flow
  • Structs
  • Arrays Maps
  • Try Err
  • Imports
  • Math
  • Strings
  • Http Server
  • Database
  • File Io

Templates

  • Automation
  • Cli Tool
  • Crud
  • Fetch Json
  • File Server
  • Hello
  • Html Render
  • Rest Api

Operators

Assignment

OperatorUsageDescription
=x = 5Assign value (also used for equality in expressions)
(space)x 5Assign value without =

In a statement context (start of line, after identifier), = is assignment. In an expression context (inside if, etc.), = is equality comparison.

drylang
x = 5              // assignment
if x = 5 { ... }   // equality comparison

Arithmetic

OperatorExampleResult
+5 + 38
-5 - 32
*5 * 315
/10 / 33.3333...
%10 % 31

String Concatenation

The + operator concatenates strings:

drylang
greeting "Hello" + ", " + "World!"
pt greeting    // prints "Hello, World!"

If either operand is a string, the other is converted to string automatically:

drylang
pt "Age: " + 17    // prints "Age: 17"
pt "Score: " + 99,5    // prints "Score: 99.5"

Unary Minus

drylang
x -5
y -(3 + 2)

Comparison

OperatorMeaningExample
=Equalx = 5
!=Not equalx != 5
<Less thanx < 10
>Greater thanx > 10
<=Less or equalx <= 10
>=Greater or equalx >= 10

All comparison operators return t or f.

drylang
pt 5 = 5       // prints "t"
pt 5 != 3      // prints "t"
pt 10 < 20     // prints "t"
pt 10 >= 10    // prints "t"

Logical

OperatorMeaningExample
&ANDa & b
|ORa | b
!NOT!a
drylang
online t
admin t

if online & admin {
  pt "Welcome, admin!"
}

if !online {
  pt "You are offline"
}

active t
premium f
if active | premium {
  pt "Access granted"
}

Operator Precedence

From lowest to highest:

PrecedenceOperators
1 (lowest)|
2&
3= !=
4< > <= >=
5+ -
6* / %
7! - (unary)
8 (highest)() [] . (call, index, access)

Use parentheses to override precedence:

drylang
result (a + b) * c
PreviousTypesNextComments