Add elvis operator for indexing.

This commit is contained in:
Stephen Chung
2022-06-12 00:32:12 +08:00
parent b9cbeb65d6
commit 2b44778a5c
7 changed files with 88 additions and 16 deletions

View File

@@ -405,3 +405,14 @@ fn test_arrays_map_reduce() -> Result<(), Box<EvalAltResult>> {
Ok(())
}
#[test]
fn test_arrays_elvis() -> Result<(), Box<EvalAltResult>> {
let engine = Engine::new();
assert_eq!(engine.eval::<()>("let x = (); x?[2]")?, ());
engine.run("let x = (); x?[2] = 42")?;
Ok(())
}