Skip to content

Misleading return types for range indexing: sub-array vs span #17912

Description

@petrroll

The document doesn't explicitely mention the implications of range indexing for arrays (that are used in examples): that it creates a subarray that's a copy and not just a view (slice) while the used language creates subrange IMO hints that it's creating the latter.

This is further worsened by one of the examples Span<int> x_y = numbers[x..y]; that suggests the idea that in this case a Slice is returned. But in reality a subarray (i.e. copy) is returned and then it's implicitly converted to Span.


Document Details

Do not edit this section. It is required for docs.microsoft.com ➟ GitHub issue linking.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions