KX Community

Find answers, ask questions, and connect with our KX Community around the world.
KX Community Guidelines

Home Forums kdb+ Optional parameter in a function

  • Optional parameter in a function

    Posted by Johnzerno on April 10, 2025 at 1:40 pm

    Is there a way to have an optional parameter in a function, and if this parameter is not supplied the function logic will behave differently?

    I would want the function to act like the below.

    func:{[requiredParam;requiredParam2;optionalParam]

                  logic if optionalParam is supplied

                  logic if optionalParam is not supplied}

    unterrainer_ale replied 1 week, 1 day ago 2 Members · 1 Reply
  • 1 Reply
  • unterrainer_ale

    Member
    April 10, 2025 at 1:44 pm

    The way you can solve this is by using a dictionary as parameter, mapping each parameter name as key to a value. You can then check if a certain parameter is in the parameter names (using key). This also allows you to pass more than 8 parameters to a function

Log in to reply.