Object Operations
Basic Operations
Objects in OSL provide various ways to access and modify their properties:
obj = {x: 1, y: 2}
// Accessing properties
val1 = obj.x // Using dot notation
val2 = obj["x"] // Using bracket notation
// Modifying properties
obj.x = 10 // Using dot notation
obj["x"] = 10 // Using bracket notationObject Methods
// Getting object information
keys = obj.getKeys() // Returns array of keys
values = obj.getValues() // Returns array of values
// Checking for properties
exists = obj.contains("x") // Returns true/falseObject Merging
The ++ operator combines objects, preserving values from the left operand:
Using Self Reference
Objects can reference their own properties using self:
Computed Properties
Objects can include computed values when created:
Important Notes
Properties can be accessed using dot or bracket notation
The
++operator preserves left operand values in conflictsUse
selfto reference object's own properties.contains()checks for property existence.getKeys()and.getValues()return arraysComputed properties are evaluated at creation time
Objects can contain methods using
def() ->
Last updated
Was this helpful?