bbaldino
06/13/2019, 7:37 PMVector which will default instantiate the instances? i want to create a collection of a generic type (from a class generic param) but don't want to have to pass in a lambda to tell the class how to default initialize. i.e.: class Foo<StatType> {
val stats = Vector<StatType>(8)
}Pavlo Liapota
06/13/2019, 7:45 PMVector does not create default instances for its elements.
How would this work if StatType didn’t have default constructor?
You can just write:
List(8) { StatType() }bbaldino
06/13/2019, 7:46 PMPavlo Liapota
06/13/2019, 7:48 PMinitialCapacity. Size of the Vector will still be 0.bbaldino
06/13/2019, 7:49 PMstats[index].member and it works fine.bbaldino
06/13/2019, 8:10 PMbbaldino
06/13/2019, 8:10 PMelizarov
06/14/2019, 9:19 AM() -> Tbbaldino
06/14/2019, 4:20 PM