DEV Community

Cover image for Slice of cake
Jorge Araya
Jorge Araya

Posted on

2 1

Slice of cake

Is there a difference between slices and arrays? Well, if there is any, it is a difference of relations. slice depends on array, when you declare a slice in Go you get an underlying array associated with your slice, if you have several slices of the same type they may even share storage with the underlying array.

How do you create a slice?

You can use the same facilities for declaring arrays in Go, with the optional argument for "capacity" provided:

make([]int, 50, 100)
Enter fullscreen mode Exit fullscreen mode

This is the same as creating an array and slicing it:

new([100]int)[0:50]
Enter fullscreen mode Exit fullscreen mode

read more

AWS Security LIVE!

Join us for AWS Security LIVE!

Discover the future of cloud security. Tune in live for trends, tips, and solutions from AWS and AWS Partners.

Learn More

Top comments (0)

Image of Docusign

🛠️ Bring your solution into Docusign. Reach over 1.6M customers.

Docusign is now extensible. Overcome challenges with disconnected products and inaccessible data by bringing your solutions into Docusign and publishing to 1.6M customers in the App Center.

Learn more