Mojo struct
ListLiteral
The type of a literal heterogeneous list expression.
A list consists of zero or more values, separated by commas.
Parametersβ
- β*Ts (
Movable
): The type of the elements.
Fieldsβ
- βstorage (
Tuple[Ts]
): The underlying storage for the list.
Implemented traitsβ
AnyType
,
Movable
,
Sized
Methodsβ
__init__
β
__init__(inout self: Self, owned *args: *Ts)
Construct the list literal from the given values.
Args:
- β*args (
*Ts
): The init values.
__moveinit__
β
__moveinit__(inout self: Self, owned existing: Self)
Move construct the list.
Args:
- βexisting (
Self
): The value to move from.
__contains__
β
__contains__[T: EqualityComparable](self: Self, value: T) -> Bool
Determines if a given value exists in the ListLiteral.
Parameters:
- βT (
EqualityComparable
): 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: Self) -> Int
Get the list length.
Returns:
The length of this ListLiteral.
get
β
get[i: Int, T: Movable](self: Self) -> ref [*[0,0]] $1
Get a list element at the given index.
Parameters:
- βi (
Int
): The element index. - βT (
Movable
): 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!
π What went wrong?