Implement in operator

This commit is contained in:
Andrew Morris
2023-07-06 15:56:04 +10:00
parent eb95deeb5d
commit 814fb09159
13 changed files with 208 additions and 34 deletions

View File

@@ -92,6 +92,18 @@ impl ValTrait for Generator {
Ok(Val::Undefined)
}
fn has(&self, key: &Val) -> Option<bool> {
if key.to_string() == "next" {
return Some(true);
}
if let Val::Symbol(VsSymbol::ITERATOR) = key {
return Some(true);
}
Some(false)
}
fn submov(&mut self, _key: &Val, _value: Val) -> Result<(), Val> {
Err("Cannot assign to subscript of a generator".to_type_error())
}