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

Image of Datadog

The Future of AI, LLMs, and Observability on Google Cloud

Datadog sat down with Google’s Director of AI to discuss the current and future states of AI, ML, and LLMs on Google Cloud. Discover 7 key insights for technical leaders, covering everything from upskilling teams to observability best practices

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