Task

The goal is to get the properties of an object, as names, values or both.

Some languages support dynamic properties, which in general can only be inspected if a class' public API includes a way of listing them.

obj = script("MyClass").new()
obj.foo = 23
obj.bar = 42
 
-- ...
 
-- show obj's property names and values
cnt = obj.count
repeat with i = 1 to cnt
  put obj.getPropAt(i)&" = "&obj[i]
end repeat