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.

// declare a class that has fields to be listed
class Fields
	declare static field1 = "this is a static field. it will not be listed"
	declare field2
	declare field3
	declare field4
end
 
// list all the fields in the class
for fieldname in Fields.getFieldNames()
	println fieldname
end