typeover
curriculum

Curriculum Idioms & ecosystem Embedding exercise 4 · fill-word

Embedding

Type the SINGLE WORD that goes in the blank to embed Animal into Dog. (Hint: it's just the type name — no other syntax.)

TypeScript reference
Fill the blanks →

About this theme

Struct embedding gives you composition without inheritance. Embed a type as an unnamed field and its methods get promoted onto the outer struct. This is how Go does "extend a type" — by containing one. The rule: prefer composition; Go literally doesn't give you inheritance to misuse.