Learning Go Programming by Unknown
Author:Unknown
Language: eng
Format: epub, mobi
Publisher: Packt Publishing
Array length and capacity
The built-in len function returns the declared length of an array type. The built-in cap function can be used on an array to return its capacity. For instance, in the following source snippet, the array seven of type [7]string will return 7 as its length and capacity:
func main() { seven := [7]string{"grumpy", "sleepy", "bashful"} fmt.Println(len(seven), cap(seven)) }
For arrays, the cap() function always returns the same value as len(). This is because the maximum capacity of an array value is its declared length. The capacity function is better suited for use with the slice type (discussed later in the chapter).
Download
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.
Kathy Andrews Collection by Kathy Andrews(11243)
The remains of the day by Kazuo Ishiguro(8303)
Paper Towns by Green John(4727)
Spare by Prince Harry The Duke of Sussex(4721)
The Body: A Guide for Occupants by Bill Bryson(4491)
Industrial Automation from Scratch: A hands-on guide to using sensors, actuators, PLCs, HMIs, and SCADA to automate industrial processes by Olushola Akande(4266)
Be in a Treehouse by Pete Nelson(3603)
Harry Potter and the Goblet Of Fire by J.K. Rowling(3552)
Never by Ken Follett(3458)
Goodbye Paradise(3388)
Machine Learning at Scale with H2O by Gregory Keys | David Whiting(3266)
Into Thin Air by Jon Krakauer(3076)
The Remains of the Day by Kazuo Ishiguro(3075)
The Cellar by Natasha Preston(3039)
The Genius of Japanese Carpentry by Azby Brown(2995)
Drawing Shortcuts: Developing Quick Drawing Skills Using Today's Technology by Leggitt Jim(2893)
120 Days of Sodom by Marquis de Sade(2882)
Fairy Tale by Stephen King(2789)
The Man Who Died Twice by Richard Osman(2753)
