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:
@@ -84,6 +84,15 @@ static const char* libSource =
|
||||
" }\n"
|
||||
" return result\n"
|
||||
" }\n"
|
||||
"\n"
|
||||
" contains(element) {\n"
|
||||
" for (item in this) {\n"
|
||||
" if (element == item) {\n"
|
||||
" return true\n"
|
||||
" }\n"
|
||||
" }\n"
|
||||
" return false\n"
|
||||
" }\n"
|
||||
"}\n"
|
||||
"\n"
|
||||
"class Range is Sequence {}\n";
|
||||
|
||||
Reference in New Issue
Block a user