valadoc-org icon indicating copy to clipboard operation
valadoc-org copied to clipboard

Please document that an empty slice is `null`

Open rrthomas opened this issue 1 year ago • 1 comments

Describe the bug

The documentation of array slices doesn't point out that if you take a slice of an empty array of built-in type (for example uint8[]), the result is null. I assume this is correct behaviour and not a bug in the language! I see that this won't happen in general; for example, string.slice uses strndup, which will only return null on error; but I guess it will happen for slices of arrays of built-in types. Or at least, can happen; in my experiments, the data member of the array was null.

https://docs.vala.dev/tutorials/programming-language/main/02-00-basics/02-04-data-types.html

rrthomas avatar Apr 19 '25 17:04 rrthomas

See https://gitlab.gnome.org/lwildberg/vala-tutorial/-/merge_requests/17

rrthomas avatar Aug 28 '25 18:08 rrthomas