While declaring an array or a slice I'm required to specify the type of data that I want to store in the array or list.
How do I make an array that can hold data of multiple types ?
While declaring an array or a slice I'm required to specify the type of data that I want to store in the array or list.
How do I make an array that can hold data of multiple types ?
You can do something like this
mixedArray := []interface{}{"astring", 10, &Object{'hello'}}
Most likely the values that you want to hold share some behavior, in that case what you should really do is create an interface and simply make the array content type that interface.