Skip to main content
Log in

Mojo struct

VariadicList

@register_passable(trivial) struct VariadicList[type: AnyTrivialRegType]

A utility class to access variadic function arguments. Provides a "list" view of the function argument so that the size of the argument list and each individual argument can be accessed.

Parameters

  • type (AnyTrivialRegType): The type of the elements in the list.

Aliases

  • IterType = _VariadicListIter[type]:

Fields

  • value (Variadic[type]): The underlying storage for the variadic list.

Implemented traits

AnyType, Sized, UnknownDestructibility

Methods

__init__

@implicit __init__(out self, *value: type)

Constructs a VariadicList from a variadic list of arguments.

Args:

  • *value (type): The variadic argument list to construct the variadic list with.

__getitem__

__getitem__(self, idx: Int) -> type

Gets a single element on the variadic list.

Args:

  • idx (Int): The index of the element to access on the list.

Returns:

The element on the list corresponding to the given index.

__len__

__len__(self) -> Int

Gets the size of the list.

Returns:

The number of elements on the variadic list.

__iter__

__iter__(self) -> _VariadicListIter[type]

Iterate over the list.

Returns:

An iterator to the start of the list.