Skip to main content

property

Property access in Soul allows you to retrieve and modify properties of objects using dot notation. This is fundamental for working with objects, classes, and complex data structures.

Basic Property Access

Access object properties using dot notation:

Property Assignment

Modify object properties using dot notation:

Nested Property Access

Access properties of nested objects:

Property Access vs Bracket Notation

Compare dot notation with bracket notation:

Dynamic Property Access

Access properties using variables:

Property Access on Class Instances

Access properties of class instances:

Property Access with Methods

Access and call methods as properties:

Safe Property Access

Handle property access safely:

Property Existence Checking

Check if properties exist:

Property Enumeration

Iterate through object properties:

Property Validation

Validate property values:

Property Copying

Copy properties between objects:

Property Defaults

Provide default values for properties:

Property Transformation

Transform property values:

Property Access in Loops

Access properties within loops:

Property Access with Error Handling

Handle property access errors:

Property Access Patterns

Common patterns for property access:

Best Practices

  1. Use dot notation when possible: It’s more readable than bracket notation
  2. Validate objects: Check for null before accessing properties
  3. Handle missing properties: Provide defaults or error handling
  4. Use meaningful property names: Make property purpose clear
  5. Avoid deep nesting: Keep object structures reasonably flat
Property access is fundamental to working with objects in Soul. Use it safely with proper validation and error handling to create robust applications.