ESC
Type to search...
S
Soli Docs

Block Syntax

Soli supports two block termination styles: end keyword and curly braces {}. Both are interchangeable.

When to use each style

  • end - Recommended for empty blocks, simple guards, and cleaner syntax
  • {} - Useful for multi-line blocks with many statements

Functions

Using Curly Braces

def greet(name: String) {
    print("Hello, " + name + "!");
}

def add(a: Int, b: Int) -> Int {
    a + b
}

Using end Keyword

def greet(name: String) end

def add(a: Int, b: Int) -> Int {
    a + b
}

If Statements

Using Curly Braces

let age = 18;

if (age >= 18) {
    print("Adult");
}

if (age >= 21) {
    print("Can drink");
} else {
    print("Too young");
}

Using end Keyword

let age = 18;

if (age >= 18) end

if (age >= 21) end
else {
    print("Too young");
}

if (age >= 18) {
    print("Adult");
} elsif (age >= 21) end
else end

While Loops

Using Curly Braces

let i = 0;
while (i < 5) {
    print(i);
    i = i + 1;
}

Using end Keyword

let i = 0;
while (i < 5) end

let j = 0;
while (j < 5) {
    print(j);
    j = j + 1;
}

For Loops

Using Curly Braces

for item in items {
    print(item);
}

Using end Keyword

for item in items end

for item in items {
    print(item);
}

Classes

Using Curly Braces

class Person {
    name: String;

    new(name: String) {
        this.name = name;
    }

    def greet {
        print("Hello, " + this.name);
    }
}

Using end Keyword

class Person end

class Person
    name: String;

    new(name: String) end

    def greet end
end

Mixed Usage

You can freely mix both styles in the same codebase:

# Empty function - use end
def placeholder end

# Function with body - use braces
def process_data(data) {
    validate(data);
    transform(data);
    save(data);
}

# Empty class - use end
class EmptyMarker end

# Class with methods - mix both
class Service
    def init end

    def process {
        fetch_data();
    }
end

# Control flow - use end for simple guards
if user.is_admin() end

if user.is_valid() {
    authorize(user);
}

Quick Reference

Construct Braces Style end Style
Function def foo { } def foo end
If if cond { } if cond end
While while cond { } while cond end
For for x in items { } for x in items end
Class class Foo { } class Foo end