Skip to content

Delegate

Eric Yang edited this page Jun 27, 2021 · 1 revision

委托

将一个子字段field的成员都委托到当前层级。

type Animal (
    weight: i32
)
type Person (
    age: i32,
    name: string,
    as animal: Animal // delegate
)
let p: Person = new Person();
p.weight // p.animal.weight
Clone this wiki locally