-
Notifications
You must be signed in to change notification settings - Fork 544
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
Odd behaviour of Sequence.all and Sequence.any #893
Comments
The documentation is lying. `all` or `any` are tests and we expect to
return a truthy or falsy value. `element` obviously doesn't match its
criteria.
|
So the behaviour is correct, but the docs need improvement |
Yes. The behavior you describe is most likely related to something like a |
@ruby0x1 told that PR #803 is related. Would be this wording more inline with the actual behaviour? all(predicate)Tests whether all the elements in the sequence pass the predicate. Iterates over the sequence, passing each element to the function predicate. If it returns something false, stops iterating and returns false. Otherwise, returns true. any(predicate)Tests whether any element in the sequence passes the predicate. Iterates over the sequence, passing each element to the function predicate. If it returns something true, stops iterating and returns true. Otherwise, returns false. findMaybe the find(predicate) { WhereSequence.new(this, predicate).take(1) } |
Even if more more valid than before, the statement is technically wrong, the predicate only needs to return truthy/falsy values. This was made so that predicate could also act as/work with a Don't add |
There is something odd in Sequence.all and Sequence.any.
wren/src/vm/wren_core.wren
Line 12 in 3d5e68f
The docs says https://wren.io/modules/core/sequence.html
By "If it returns something false, stops iterating and returns the value" should be
if (!result) return element
instead of result?The text was updated successfully, but these errors were encountered: