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:
Kyle Marek-Spartz
2015-01-09 22:02:40 +00:00
parent e6fb918cc7
commit b949886707
3 changed files with 49 additions and 24 deletions
+9
View File
@@ -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 {}