MCPcopy Index your code
hub / github.com/aiscriptdev/aiscript / append

Function append

aiscript-vm/src/builtins/array.rs:31–47  ·  view source on GitHub ↗

Add an item to the end of the list

(
    _mc: &'gc Mutation<'gc>,
    receiver: Value<'gc>,
    args: Vec<Value<'gc>>,
)

Source from the content-addressed store, hash-verified

29
30// Add an item to the end of the list
31fn append<'gc>(
32 _mc: &'gc Mutation<'gc>,
33 receiver: Value<'gc>,
34 args: Vec<Value<'gc>>,
35) -> Result<Value<'gc>, VmError> {
36 let list = receiver.as_array()?;
37
38 if args.is_empty() {
39 return Err(VmError::RuntimeError("append: expected 1 argument".into()));
40 }
41
42 let value = args[0];
43 list.borrow_mut(_mc).push(value);
44
45 // Return the modified list for method chaining
46 Ok(receiver)
47}
48
49// Extend the list by appending all items from another list
50fn extend<'gc>(

Callers

nothing calls this directly

Calls 4

RuntimeErrorClass · 0.85
as_arrayMethod · 0.80
pushMethod · 0.80
borrow_mutMethod · 0.45

Tested by

no test coverage detected