_______ in Go allows a struct to anonymously embed other structs.
- Aggregation
- Composition
- Inheritance
- Polymorphism
Composition in Go refers to the ability to embed one struct within another struct. This feature allows the outer struct to inherit the fields and methods of the embedded struct, enabling code reuse and modular design without explicitly using inheritance.
Loading...
Related Quiz
- Which Go idiom is commonly used to handle errors by chaining them with other function calls?
- What methods are available on the template object in Go for parsing and executing templates?
- How would you approach creating a reusable package in Go for string manipulation which can be shared across multiple projects?
- How are maps initialized in Go?
- A common way to implement mocking in Go is by using _____.