Optional parameters in user defined funtions

3.15K viewsGeneral Discussion
0

Is there a way to specify an optional parameter in a function defined using QAPI?
Thank you

Davide

0

Hi BrianC, thank you for the quick and clear answer.
Davide

0

When you implement IFunction.argumentTypes(), you can specify a QType.cOptionalValueType or QType.cOptionalValueListType. For example a floor function that takes an optional decimal places argument in addition to the regular argument would look like:

public QType[] argumentTypes()
{
return new QType[] {QType.cValueType,
Type.cOptionalValueType};
}

cheers