Property and Index Access

Jyro provides dot notation and bracket notation for accessing properties and elements on objects, arrays, and strings.

Dot Notation

Access object properties by name:

obj.name                 # Property access
obj.address.city         # Nested property traversal

Bracket Notation

Access array elements by index (zero-based), object properties by key, or string characters by position:

arr[0]                   # Array element (first)
obj["key"]               # Object property (for dynamic keys)
str[0]                   # String character (returns single-char string)

Bracket notation supports dynamic keys via expressions:

var field = "name"
var value = obj[field]   # Equivalent to obj.name

Null Behaviour

  • Property access on an object returns null if the property does not exist
  • Index access returns null if the index is out of bounds or the key is missing
  • Accessing a property on null causes a runtime error - guard with null checks
# Safe access pattern using short-circuit evaluation
if Data.user is not null and Data.user.profile is not null then
    Data.userName = Data.user.profile.name
else
    Data.userName = "Guest"
end

# Or use null coalescing for simple defaults
var name = Data.user.name ?? "Unknown"

Assignment

Properties and indexes are assignable:

obj.name = "Bob"
arr[0] = 99
obj["dynamicKey"] = "value"

Keywords as Property Names

Keywords are valid as property names when accessed via dot notation or bracket notation. This only applies to member access on objects - it does not allow keywords as local variable names.

Data.for = "loop data"         # Valid
Data.number = 42               # Valid
Data.string = "text"           # Valid
var value = Data["default"]    # Valid

# var for = "x"                # INVALID - syntax error

Back to top

Copyright © Mesch Systems 2025-2026. All rights reserved.