feat: make Sequence.all() and Sequence.any() return actual predicate values instead of booleans
Rewrite all() and any() to store and return the predicate's result directly, matching && and || semantics. Update documentation to describe the new behavior. Move tests from test/core/list/ to test/core/sequence/ and add cases verifying that the first falsey/truthy value is returned.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
var a = [1, 2, 3]
|
||||
IO.print(a.all {|x| x > 1 }) // expect: false
|
||||
IO.print(a.all {|x| x > 0 }) // expect: true
|
||||
IO.print([].all {|x| false }) // expect: true
|
||||
|
||||
// Returns first falsey value.
|
||||
IO.print(a.all {|x| x < 2 ? null : false }) // expect: null
|
||||
|
||||
// Returns last truthy value.
|
||||
IO.print(a.all {|x| x }) // expect: 3
|
||||
Reference in New Issue
Block a user