What are the differences in len() and cap() functions of slice in go?
Answer Posted / Priyanka Rani
The len() function returns the number of elements that a slice currently contains, while cap() returns the allocated capacity of the slice. If the capacity of a slice is not sufficient to append additional elements using the append() function, it will grow automatically when needed until its capacity matches the length.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
No New Questions to Answer in this Category !! You can
Post New Questions
Answer Questions in Different Category