feat: add contains method to List and update Set example to new operator syntax
Add a `contains(element)` method to the `List` class in the core library, enabling linear search for an element across all list items. Update the `example/set.wren` file to use the new Wren operator syntax for `|`, `+`, `&`, and `-` methods, replacing old function-style parameter definitions with block-style closures. Also fix trailing whitespace throughout the Set example and embed the new `contains` method into the C source string in `src/wren_core.c` for the built-in List class.
This commit is contained in:
@@ -41,6 +41,15 @@ class List is Sequence {
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
contains(element) {
|
||||
for (item in this) {
|
||||
if (element == item) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
class Range is Sequence {}
|
||||
|
||||
Reference in New Issue
Block a user