feat(array): add an empty getter for arrays.

This commit is contained in:
ltabis
2022-08-23 16:36:43 +02:00
parent 56b732d83b
commit 9c3443538a
2 changed files with 8 additions and 0 deletions

View File

@@ -30,6 +30,11 @@ pub mod array_functions {
pub fn len(array: &mut Array) -> INT {
array.len() as INT
}
/// Return true if the array is empty.
#[rhai_fn(name = "empty", get = "empty", pure)]
pub fn empty(array: &mut Array) -> bool {
array.len() == 0
}
/// Get a copy of the element at the `index` position in the array.
///
/// * If `index` < 0, position counts from the end of the array (`-1` is the last element).