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

.some() method behaves unexpectedly #945

Closed
bwaldon opened this issue Dec 12, 2022 · 2 comments
Closed

.some() method behaves unexpectedly #945

bwaldon opened this issue Dec 12, 2022 · 2 comments

Comments

@bwaldon
Copy link

bwaldon commented Dec 12, 2022

The following code returns true in the online WebPPL interpreter, but should return false:

var array = [{x:"x1", y:"y1"}, {x:"x1", y:"y2"}]

console.log(array.some(function(item){
  return(item.x === "x1" && item.y === "y3")
  }))
@null-a
Copy link
Member

null-a commented Dec 12, 2022

The problem here is that (a) array.some is calling out to a JS function and (b) the JS function is passed a webppl function as an argument, which isn't supported -- see point 2 here. (Of course, it would be nice if this was an error of some kind.) Instead, you can use the webppl function any. (Docs here.)

@null-a null-a closed this as completed Dec 12, 2022
@bwaldon
Copy link
Author

bwaldon commented Dec 12, 2022

Missed this in the documentation — thanks!

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