Mojo struct
ValueOrUnknown
struct ValueOrUnknown[dim: Int = -1]
Represents either a static dimension (known at compile time) or a dynamic dimension (known at runtime).
Parameters
- dim (
Int
): Optional compile-time dimension value. Default isUNKNOWN_VALUE
for dynamic dimensions.
Fields
- value (
Int
): The runtime value of the dimension.
Implemented traits
AnyType
,
UnknownDestructibility
Methods
__init__
__init__(out self)
Initializes a static dimension with compile-time value.
Note:
Fails to compile if dim is UNKNOWN_VALUE
, as dynamic dimensions require a runtime value.
@implicit
__init__(out self, v: Int)
Initializes a dynamic dimension with runtime value.
Args:
- v (
Int
): Runtime value for the dimension.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!