Match the Unknown value to parameters
- Last Updated: June 1, 2021
- 2 minute read
- OpenEdge
- Version 13.0
- Documentation
When passing the Unknown value (?) for a given
parameter, ABL only selects a method or constructor to invoke if
the Unknown value (?) causes no compile-time ambiguity among
overloadings. If there are multiple methods or constructors with
corresponding parameters being passed the Unknown value (?),
ABL raises a compile-time ambiguity error. You can avoid ambiguity
with the Unknown value (?) by converting it to a known
data type using a data type conversion function or by assigning
it to a variable, data member, or property, then passing the converted
value, variable, data member, or property as the parameter.
The following example shows one overloaded method call using
the Unknown value (?) without ambiguity and another overloaded
method call using the Unknown value (?) with ambiguity:
|
The two calls to these methods resolve as follows, according to the bold-faced code comments:
- The first passed parameter with the
Unknown value (?)matches the first parameter of either method. However, because the passed parameter value of12for the second parameter can match only the secondINTEGERparameter of the first method version, ABL matches the call to this first version. - The second passed parameter with the
Unknown value (?)matches the second parameter of either method. Because the passed parameter value of"Frank"for the first parameter can also match the first parameter of either method, ABL cannot choose a match and raises a compile-time ambiguity error.
However, the following procedure calls the same methods in the
previous Unknown class without ambiguity, because
it ensures that every Unknown value (?) parameter is converted
to a specific data type:
|
The two calls to these methods resolve as follows, according to the bold-faced code comments:
- Passes an
Unknown value (?)converted to theCHARACTERdata type for the second parameter using theSTRINGbuilt-in function. ABL therefore matches the second version of thesetUnknowns( )method, whose second parameter is defined as aCHARACTER - Passes an
Unknown value (?)converted to theINTEGERdata type by first assigning theUnknown value (?)to anINTEGERvariable, then passing this variable as the second parameter value. ABL therefore matches the first version of thesetUnknowns( )method, whose second parameter is defined as anINTEGER.