Add an item to the end of the list
(
_mc: &'gc Mutation<'gc>,
receiver: Value<'gc>,
args: Vec<Value<'gc>>,
)
| 29 | |
| 30 | // Add an item to the end of the list |
| 31 | fn 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 |
| 50 | fn extend<'gc>( |
nothing calls this directly
no test coverage detected