reflect.Type.getKind
Returns the kind of a type.
Syntax
getKind()
RETURNS STRING
- Possible returned values:
PRIMITIVE
,RECORD
,ARRAY
,DICTIONARY
,FUNCTION
,INTERFACE
.
Usage
The getKind()
method returns the kind of this reflect.Type
object.
The kind can be:
"PRIMITIVE"
for primitive data types (INTEGER
,VARCHAR(50)
, etc)"RECORD"
, when the object type represents a structured record (with or without associated methods)."ARRAY"
when the object type represents a dynamic array or static array."DICTIONARY"
when the object type represents a dictionary."FUNCTION"
when the object type represents a function type."INTERFACE"
when the object type represents an interface type.
Tip:
Based on the kind of the reflect.Type
object, use the methods
corresponding to that kind: getElementType()
for "ARRAY"
or
"DICTIONARY"
, getMethod()
for "INTERFACE"
,
etc.
Example
IMPORT reflect
MAIN
DEFINE arr DYNAMIC ARRAY OF STRING
DEFINE dic DICTIONARY OF STRING
DEFINE rec RECORD pkey INT END RECORD
DEFINE dtm DATETIME YEAR TO FRACTION(5)
DISPLAY "arr kind = ", reflect.Type.typeOf(arr).getKind()
DISPLAY "dic kind = ", reflect.Type.typeOf(dic).getKind()
DISPLAY "rec kind = ", reflect.Type.typeOf(rec).getKind()
DISPLAY "dtm kind = ", reflect.Type.typeOf(dtm).getKind()
END MAIN
Shows:
arr kind = ARRAY
dic kind = DICTIONARY
rec kind = RECORD
dtm kind = PRIMITIVE