Skip to main content

map

Maps in Soul are unordered collections of key-value pairs, similar to dictionaries or objects in other languages. They are created using curly braces {} and provide efficient lookup and modification of data.

Basic Map Creation

Create maps with curly brace notation:

Accessing Map Values

Use bracket notation or dot notation to access values:

Modifying Map Values

Add or change values using assignment:

Map Methods

Common map operations:

Map Iteration

Iterate through map key-value pairs:

Nested Maps

Maps can contain other maps:

Map with Different Value Types

Maps can store different types of values:

Map Copying

Create copies of maps:

Map Merging

Combine multiple maps:

Map Filtering

Filter map entries based on conditions:

Map Transformation

Transform map values:

Map Searching

Find entries in maps:

Map Validation

Validate map structure and content:

Map Utilities

Common map utility functions:

Map Configuration

Use maps for configuration:

Map as Cache

Use maps for caching:

Map Performance

Optimize map operations:

Best Practices

  1. Use meaningful keys: Choose descriptive key names
  2. Check key existence: Verify keys exist before accessing
  3. Handle null values: Account for missing or null values
  4. Use consistent types: Keep key types consistent within a map
  5. Validate structure: Check map structure before use
Maps are essential data structures in Soul, providing efficient key-value storage and retrieval for organizing and managing data in your applications.