Skip to content

spec: make slice when capacity is unspecified #4768

@btracey

Description

@btracey
Currently if the capacity of a slice is unspecified during a make call, the slice is
created with the capacity equal to the length. As far as I can tell, the spec does not
specify this behavior. Can this behavior be counted on, or if I want to ensure the slice
does not use up extra memory do I need to call 
s := make([]T, len, len) ?

A clarification in the spec either way would be nice.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions