Mojo function
reflect
reflect[T: AnyType]() -> Reflected[T]
Returns a compile-time reflection handle for type T.
Example:
from std.reflection import reflect
struct Point:
var x: Int
var y: Float64
def main():
comptime r = reflect[Point]()
print(r.field_count()) # 2Parameters:
- T (
AnyType): The type to introspect.
Returns:
Reflected[T]: A Reflected[T] handle exposing introspection methods.
Was this page helpful?
Thank you! We'll create more content like this.
Thank you for helping us improve!