API Reference › Reflect › Reflect.field_count
method

Reflect.field_count

Reflect.field_count(prop) -> int

Returns the number of fields in property prop. Walk 0 .. Reflect.field_count(prop) with Reflect.field_name and Reflect.field_type to enumerate a component's shape.

Parameters

propa property id (from Reflect.prop)

Example

program Demo {
  property Health { hp: int = 0, max: int = 0 }
  model Unit { Health }
  entry {
    print(Reflect.field_count(Reflect.prop("Health")))   # 2
  }
}
← All symbols