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

Inconsistent numeric var behaviour #110

Open
JTeeuwissen opened this issue Feb 23, 2022 · 2 comments
Open

Inconsistent numeric var behaviour #110

JTeeuwissen opened this issue Feb 23, 2022 · 2 comments

Comments

@JTeeuwissen
Copy link

JTeeuwissen commented Feb 23, 2022

logic: {"var":0.1}
data: ["ab", "cd"]
evaluates to: "b"

while

logic: {"var":1.0}
data: ["ab", "cd"]
evaluates to: "cd"

presumably because:

>>> JSON.stringify(1.0)
"1"

A solution would be to always round number, making sub-indexing impossible without strings.

@jwadhams
Copy link
Owner

I can honestly say I never considered this. The var operation casts its input to a String before using it this is especially to support sub-indexing (which is accomplished with String.split)

Does it meet your needs to use logic like
{"var":"0.1"}
{"var":"1.0"}

@JTeeuwissen
Copy link
Author

Using strings is indeed a solution. But on the example page numeric values are used for indexing arrays. So I'd thought I mention it here so you are aware.

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