package mantra.lang

List

CLASS public class List

Dynamic heterogeneous resizable array implementation backed by contiguous heap storage with amortized O(1) appends.

🏗️ Constructor Summary

Constructor Signature
def __init__(self)

⚙️ Method Summary

Modifier & Return Type Method Signature Description
Void append(item: T) Appends an element to the end of the dynamic list.
T pop() Removes and returns the last element from the list.
Int len() Returns the current number of elements.
T get(index: Int) Returns element at specified index with bounds checking.

🔍 Detailed Method Specifications

pub def append(item: T) -> Void
Appends an element to the end of the dynamic list.
pub def pop() -> T
Removes and returns the last element from the list.
pub def len() -> Int
Returns the current number of elements.
pub def get(index: Int) -> T
Returns element at specified index with bounds checking.

💡 Example Usage

list_example.mantra
let numbers = [10, 20, 30]
numbers.append(40)
print("Count: " + str(numbers.len()))
let last = numbers.pop() # 40