What are the differences in len() and cap() functions of slice in go?
Answer / 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 |
What is gopath environment variable?
Who is known as the father of go programming language?
What type assertion is used for and how it does it?
Is “maps” value types?
What is type assertion in go?
What is difference between concurrent and parallel in golang?
What is gopath environment variable in go programming?
Explain what a modular programming language is?
What is the default value of a pointer variable in go?
How pointer is represented in go?
Why does my go process use a lot of virtual memory?
What is string literals?