Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should it be explained more thoroughly that a a function returns a projection? #108

Open
b-enoit-be opened this issue Sep 3, 2022 · 1 comment

Comments

@b-enoit-be
Copy link

b-enoit-be commented Sep 3, 2022

Let's say we have a list of list and want to select the sublist where a string starts with a letter.

So, given the JSON

[
    [
        "ab",
        "cd"
    ],
    [
        "ef",
        "gh"
    ]
]

One could do:

[?contains([].starts_with(@, `a`), `true`)]

But, in order to have a consistent notation, I was trying to make the contains function a dot notation too, so:

[?[].starts_with(@, `a`).contains(@, `true`)]

which does not work.

I figured out it as because starts_with returns a projection, so it can be achieved resetting it:

[?[].starts_with(@, `a`) | contains(@, `true`)]

But I feel, for a new comer that does not know that well about projections and resetting them, it should be explained in the specification in more details, shouldn't it?

@springcomp
Copy link
Contributor

Yes, it definitely should be explained better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants