How is len() different from cap() function?

  • len() function returns elements that are present in the slice.
  • cap() function returns capacity of slice, which refers to the number of elements it can be accommodated.

This is one of the frequently asked go programming interview questions.

Suggest An Answer

No suggestions avaliable!

Related Interview Questions