Reflection/List properties: Difference between revisions

No edit summary
Line 1,087:
clazz.getDeclaredFields.foreach(f => println(s"${f}}"))
}</lang>
 
=={{header|Smalltalk}}==
for names of slots defined in the class (excludes inherited):
<lang smalltalk>someObject class instVarNames</lang>
for all slot names (incl. inherited):
<lang>someObject class allInstVarNames</lang>
to get a Dictionary (aka. HashTable) mapping names to values:
<lang>someObject class allInstVarNames collect:[:nm | nm -> (someObject instVarNamed:nm)] as:Dictionary</lang>
 
A class can make this a secret by redefining #instVar access to eg. raise an exception.
Notice: this is not considered good Smalltalk style - it should be used by debuggers and object inspectors only, except for special frameworks (such as code generators etc.).
 
=={{header|Tcl}}==
Anonymous user