3 ms·
D slices can be null, but they're not a mistake, as the runtime will not let you read/write a 0 length array.
by WalterBright 4y ago
D slices can be null, but they're not a mistake, as the runtime will not let you read/write a 0 length array.
- saagarjha 4y agoWhat's the relation between a null slice and a 0-length array?
- WalterBright 4y agoNeither can be successfully indexed.
- feffe 4y agoPerhaps this is similar to how they work in go? "var x []int; fmt.Printf(`%p %d`, x, len(x))" outputs "0x0 0" Indexing "x[0]" results in: "panic: runtime error: index out of range [0] with length 0" They can also be appended to and then produce a valid slice.