Junior — Middle
Can you give examples of data types that can be stored in a Nested structure?
sobes.tech AI
Answer from AI
In Go's Nested structure, you can store various data types, including:
- Nested structures (struct), which allow creating hierarchical data.
- Slices and arrays, e.g., []int, []string.
- Primitive types: int, float64, string, bool.
- Maps, if you need to store associative data.
Example:
type Address struct {
City string
ZipCode int
}
type Person struct {
Name string
Age int
Address Address
Tags []string
}
Here, the Person structure contains a nested Address structure and a slice of strings Tags.