-
Notifications
You must be signed in to change notification settings - Fork 1
Empty places in struct slice get filled with reference #61
Copy link
Copy link
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Empty places in struct slice get filled with reference. This means if an index gets set which is not yet available, all the indices prior to the set one get filled with the same reference to the default struct. Therefore, like shown in the example below, if an index in between gets set, all the other the other inserted index-places will hold the same value.
type easyStruct struct {
a string
}
sl := []easyStruct{}
sl[2] = easyStruct{a: "Hello"}
sl[1].a = "World"
print(sl[0].a) // Results in "World".This could be solved by either creating a completely new struct for each intermediate index or by just not assigning it at all.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working