Object methods

Objects include properties and methods to manage their keys and values.

Properties#

PropertyDescription
lenNumber of keys in the object
object = { name "John" age 30 }

print object.len # 2

Methods#

MethodDescription
keys()Array with all keys
values()Array with all values
get(key)Returns the value associated with the key
set(key value)Adds or updates a key with a value
delete(key)Removes a key and its value
has(key)true if the key exists
clear()Removes all properties from the object

Examples#

Query information#

person = {
    name "John"
    age 30
}

print person.len       # 2
print person.keys()    # ["name" "age"]
print person.values()  # ["John" 30]

if person.has("name")
    print person.get("name")  # John

Modify properties#

person = { name "John" }

person.set "age" 30
person.set "name" "Carlos"
print person

person.delete "name"
print person
person.clear

print person.len  # 0