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
end

If Statements

Using Curly Braces

age = 18

if age >= 18
  print("Adult")
end

if age >= 21
  print("Can drink")
else
  print("Too young")
end

Using end Keyword

age = 18

if age >= 18
  print("Adult")
end

if age >= 21
  print("Can drink")
else
  print("Too young")
end

While Loops

Using Curly Braces

i = 0
while i < 5
  print(i)
  i = i + 1
end

Using end Keyword

i = 0
while i < 5
end

j = 0
while j < 5
  print(j)
  j = j + 1
end

For Loops

Using Curly Braces

for item in items
  print(item)
end

Using end Keyword

for item in items end

for item in items
  print(item)
end

Classes

Using Curly Braces

class Person
  name: String

  new(name: String)
    this.name = name
  end

  def greet
    print("Hello, " + this.name)
  end
end

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 end
def process_data(data)
  validate(data)
  transform(data)
  save(data)
end

# Empty class - use end
class EmptyMarker end

# Class with methods - use end
class Service
  def init end

  def process
    fetch_data()
  end
end

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

if user.is_valid()
  authorize(user)
end

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