Skip to content

Accessing arguments in variadic functions #195

@deepilla

Description

@deepilla
Contributor

JSONata allows you to define functions that accept a variable number of arguments. But I can't work out how to access those arguments from within a lambda function. Perhaps this is only possible in JavaScript extensions.

Let's say I need a function that takes one or more numeric arguments and returns the total. What do I put in the function body to make the expression below return 6?

(
    $f := function($x)<n+:n>{ ... };
    $f(1, 2, 3)
)

Activity

andrew-coleman

andrew-coleman commented on Apr 18, 2018

@andrew-coleman
Member

You're right, this is only possible in extension functions. I'll flag this as an enhancement request.
Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @deepilla@andrew-coleman

        Issue actions

          Accessing arguments in variadic functions · Issue #195 · jsonata-js/jsonata