Resize / Reserve with a dynamic array in Overview commented output is incorrect
mahSource opened this issue · 0 comments
mahSource commented
The examples have output for the fmt.println(len(x), cap(x)) that show elements with commas, they are/should be space delimited in the output
See: https://odin-lang.org/docs/overview/#resize--reserve-with-a-dynamic-array
.
This is the current Overview Example
x: [dynamic]int
fmt.println(len(x), cap(x)) // 0, 0
append(&x, 1, 2, 3) // [1, 2, 3]
fmt.println(len(x), cap(x)) // 3, 8
resize(&x, 5)
fmt.println(x[:]) // [1, 2, 3, 0, 0] other values are zero'd memory
fmt.println(len(x), cap(x)) // 5, 8
reserve(&x, 32)
fmt.println(len(x), cap(x)) // 5, 32
shrink(&x)
fmt.println(len(x), cap(x)) // 5, 5
Suggest the Overview be updated to this
x: [dynamic]int
fmt.println(len(x), cap(x)) // 0 0
append(&x, 1, 2, 3) // [1, 2, 3]
fmt.println(len(x), cap(x)) // 3 8
resize(&x, 5)
fmt.println(x[:]) // [1, 2, 3, 0, 0] other values are zero'd memory
fmt.println(len(x), cap(x)) // 5 8
reserve(&x, 32)
fmt.println(len(x), cap(x)) // 5 32
shrink(&x)
fmt.println(len(x), cap(x)) // 5 5
.
Notice the commas for the output of 5 lines are removed....a minor update, but should be changed to this.