Files
wren/test/core/sequence/any.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

11 lines
317 B
Plaintext

var a = [1, 2, 3]
IO.print(a.any {|x| x > 3 }) // expect: false
IO.print(a.any {|x| x > 1 }) // expect: true
IO.print([].any {|x| true }) // expect: false
// Returns first truthy value.
IO.print(a.any {|x| x }) // expect: 1
// Returns last falsey value.
IO.print(a.any {|x| x < 2 ? null : false }) // expect: false