Skip to main content

assign

Assignment is the fundamental way to store values in variables in Soul. The language supports several types of assignment operations.

Basic Assignment

Soul uses the = operator for basic assignment. Variables are dynamically typed and created upon first assignment.

Compound Assignment

Soul supports compound assignment operators that combine arithmetic operations with assignment:

Assignment to Collections

You can assign values to list elements and map properties:

Multiple Assignment Patterns

Soul supports various assignment patterns for different data structures:

Assignment in Control Flow

Assignments can be used within control flow structures:

Best Practices

  1. Use descriptive variable names: userCount instead of c
  2. Initialize variables: Assign initial values when declaring variables
  3. Consistent naming: Use camelCase for variable names
  4. Avoid reassigning different types: Keep variable types consistent when possible