Reflection/List properties: Difference between revisions

Add Ecstasy example
imported>Arakov
(Add Ecstasy example)
 
(2 intermediate revisions by 2 users not shown)
Line 96:
Properties of C:
b</pre>
 
=={{header|Ecstasy}}==
For any object, the type of that object provides access to its properties:
 
<syntaxhighlight lang="ecstasy">
module test {
void run() {
@Inject Console console;
Property[] properties = &this.actualType.properties;
console.print($"The properties of {this}: {properties}");
}
}
</syntaxhighlight>
 
{{out}}
<pre>
x$ xec test
The properties of test: [immutable Array<Class<Object, Object, Object, Struct>> classes, immutable Map<String, Class<Object, Object, Object, Struct>> classByName, String simpleName, String qualifiedName, Version version, immutable Map<String, Module> modulesByPath]
</pre>
 
=={{header|Elena}}==
Line 118 ⟶ 137:
};
 
MyClass.__getProperties().forEach::(p)
{
console.printLine("o.",p,"=",p.getPropertyValue(o))
Line 1,168 ⟶ 1,187:
 
Note that, since attributes are stored internally as a map, the order in which the property names appear is undefined.
<syntaxhighlight lang="ecmascriptwren">#! instance_methods(m, n, o)
#! instance_properties(p, q, r)
class C {
162

edits