1
0
forked from Mirror/wren
Files
wren/test/core/sequence/all.wren
Bob Nystrom 07f9d4d2be Tweak Sequence.all() and Sequence.any().
When possible, they return the actual value from the predicate
instead of always just "true" and "false". This matches && and ||
which evaluate to the RHS or LHS when appropriate.
2015-03-28 10:18:45 -07:00

10 lines
315 B
Plaintext

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