Mojo struct
ListLiteral
The type of a literal heterogeneous list expression.
A list consists of zero or more values, separated by commas.
Parameters
- *Ts (
CollectionElement
): The type of the elements.
Fields
- storage (
Tuple[Ts]
): The underlying storage for the list.
Implemented traits
AnyType
,
CollectionElement
,
Copyable
,
Movable
,
Sized
Methods
__init__
__init__(out self, owned *args: *Ts)
Construct the list literal from the given values.
Args:
- *args (
*Ts
): The init values.
__copyinit__
__copyinit__(out self, existing: Self)
Copy construct the tuple.
Args:
- existing (
Self
): The value to copy from.
__moveinit__
__moveinit__(out self, owned existing: Self)
Move construct the list.
Args:
- existing (
Self
): The value to move from.
__contains__
__contains__[T: EqualityComparableCollectionElement](self, value: T) -> Bool
Determines if a given value exists in the ListLiteral.
Parameters:
- T (
EqualityComparableCollectionElement
): The type of the value to search for. Must implement theEqualityComparable
trait.
Args:
- value (
T
): The value to search for in the ListLiteral.
Returns:
True if the value is found in the ListLiteral, False otherwise.
__len__
__len__(self) -> Int
Get the list length.
Returns:
The length of this ListLiteral.
get
get[i: Int, T: CollectionElement](self) -> ref [*[0,0].storage] $1
Get a list element at the given index.
Parameters:
- i (
Int
): The element index. - T (
CollectionElement
): The element type.
Returns:
The element at the given index.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!