Grokking Go
0% completed
Shorthand Declaration of Array
In Go, arrays can be declared and initialized in a single line using shorthand declaration. This method makes the code cleaner and more readable, avoiding separate assignments.
Unlike the traditional method, where values are assigned later, the shorthand declaration immediately assigns values at the time of creation.
Shorthand Declaration of an Array
Go provides two shorthand ways to declare and initialize an array:
- Specifying the size explicitly.
- Using
...(ellipsis) to infer the size automatically.
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%