MCPcopy Create free account
hub / github.com/SincereCSL/Playgrounds / getPet

Function getPet

TypeScript/StudyTypeScript/src/advanced_01.ts:33–38  ·  view source on GitHub ↗
(master: Master)

Source from the content-addressed store, hash-verified

31}
32enum Master { Boy, Girl}
33function getPet(master: Master){
34 let pet = master === Master.Boy ? new DogA() :new CatA();
35 pet.eat();
36 // pet.run();
37 return pet
38}
39
40// 可区分的联合类型 (结合了联合类型和字面量类型保护方法)
41

Callers

nothing calls this directly

Calls 1

eatMethod · 0.65

Tested by

no test coverage detected