API Reference › Reflect › Reflect.field_name
method

Reflect.field_name

Reflect.field_name(prop, index) -> string

Returns the name of the field at index within property prop (0 .. Reflect.field_count(prop)), or the empty string if out of range. The key half of a generic serializer or inspector row.

Parameters

propa property id (from Reflect.prop)
indexthe field index

Example

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