User Tools

Site Tools


reflection-field-selection

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
reflection-field-selection [2019/10/19 17:00]
barryfp
reflection-field-selection [2020/02/11 06:21] (current)
barryfp [Reflection]
Line 7: Line 7:
 ''​DataType.[fieldName]''​ ''​DataType.[fieldName]''​
  
-or+Or for functions with:
  
-''​dataInstance.["​fieldname"​]''​ +''​DataType.[functionName()]''​
- +
-The first variant is used with the literal data type itself, while the second variant is used on an instance of the data type, in which the particular field you would like chosen using its string name.+
  
 As an example, we can get a TypeField as follows: As an example, we can get a TypeField as follows:
Line 70: Line 68:
  
 This will create a new data instance with all of the fields given in the type ''​t''​. This will create a new data instance with all of the fields given in the type ''​t''​.
 +
 +For arrays, we can combine type assignment with value construction,​ using the syntax:
 +
 +''​Data d[] = new Data[](a, b) from t''​
  
 Combined with field selection, reflection allows you to create new data types and populate all of their fields in a completely dynamic way. Combined with field selection, reflection allows you to create new data types and populate all of their fields in a completely dynamic way.
reflection-field-selection.1571518840.txt.gz · Last modified: 2019/10/19 17:00 by barryfp