feat: add Sequence.any method and update docs, tests, and core source
Implement the `any` method on the Sequence class that returns true if any element passes the given predicate function. Update the core.wren library source, the C embedded source string in wren_core.c, and add comprehensive test files for normal usage, non-bool return values, and non-function argument error handling. Also fix a typo in the QA documentation and correct the initial account balance in the example.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
var a = [1, 2, 3]
|
||||
|
||||
var b = a.any {|x| x > 3 }
|
||||
IO.print(b) // expect: false
|
||||
|
||||
var d = a.any {|x| x > 1 }
|
||||
IO.print(d) // expect: true
|
||||
|
||||
var e = [].any {|x| true }
|
||||
IO.print(e) // expect: false
|
||||
@@ -0,0 +1 @@
|
||||
IO.print([1, 2, 3].any {|x| "truthy" }) // expect: true
|
||||
@@ -0,0 +1 @@
|
||||
[1, 2, 3].any("string") // expect runtime error: String does not implement 'call(_)'.
|
||||
Reference in New Issue
Block a user