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.

import system'routines;
import system'dynamic;
import extensions;
 
class MyClass
{
    prop int X;
    prop string Y;
}
 
public program()
{
    var o := new MyClass
    {
        this X := 2;
 
        this Y := "String";
    };
 
    MyClass.__getProperties().forEach:(p)
    {
        console.printLine("o.",p,"=",cast MessageName(p).getPropertyValue(o))
    }
}