Skip to main content

expression

Expression statements are standalone expressions that are evaluated for their side effects. They represent expressions that are used as statements in Soul programs.

Basic Expression Statements

Simple expressions used as statements:

Arithmetic Expression Statements

Arithmetic operations used as statements:

Comparison Expression Statements

Comparison operations used as statements:

Logical Expression Statements

Logical operations used as statements:

Function Call Expression Statements

Function calls used as statements:

Object Property Expression Statements

Property access and modification as statements:

Array/List Expression Statements

Array and list operations as statements:

Conditional Expression Statements

Ternary and conditional expressions as statements:

Complex Expression Statements

Multi-part expressions used as statements:

Expression Statements in Control Flow

Expressions used within control structures:

Side Effect Expression Statements

Expressions that produce side effects:

Async Expression Statements

Asynchronous expressions as statements:

Expression Statements with Error Handling

Expressions within try-catch blocks:

Chain Expression Statements

Method chaining expressions:

Expression Statements in Loops

Expressions used in loop contexts:

Best Practices

  1. Keep expressions readable: Break complex expressions into simpler parts
  2. Use meaningful variable names: Make expression purpose clear
  3. Avoid side effects in comparisons: Keep comparisons pure
  4. Use parentheses for clarity: Group operations logically
Expression statements form the foundation of Soul programs, allowing you to perform calculations, call functions, and manipulate data as part of your program’s execution flow.