The reflect.Value class
The reflect.Value
class is a generic API to inspect and modify
variables.
This class is provided in the
reflect
C-Extension library; To use this class, import the reflect
package
with:IMPORT reflect
A reflect.Value
object is the runtime representation of a variable.
A call to reflect.Value returns an object representing the type and data of a variable at runtime.
Each variable has a Type. Several methods of this API are restricted to certain kinds of Types.
For example, the method insertArrayElement()
is restricted to the kind "ARRAY"
.
The program should check the kind of a type before calling kind-specific functions.
Important:
The exceptions thrown by the
reflect.*
API can only be caught with a TRY/CATCH
block: If WHENEVER
ERROR CONTINUE
is active and the reflection API throws an exception, the program
stops.