Course Hive
Search

Welcome

Sign in or create your account

Continue with Google
or
Cap. 8 – Agrupamentos de Dados – 6. Slice: make
Play lesson

Aprenda Go 🇧🇷 - Cap. 8 – Agrupamentos de Dados – 6. Slice: make

5.0 (2)
47 learners

What you'll learn

This course includes

  • 21.3 hours of video
  • Certificate of completion
  • Access on mobile and TV

Summary

Keywords

Full Transcript

- Slices são feitas de arrays. - Elas são dinâmicas, podem mudar de tamanho. - Sempre que isso acontece, um novo array é criado e os dados são copiados. - É conveniente, mas tem um custo computacional. - Para otimizar as coisas, podemos utilizar make. - make([]T, len, cap) - "The length of a slice may be changed as long as it still fits within the limits of the underlying array; just assign it to a slice of itself. The capacity of a slice, accessible by the built-in function cap, reports the maximum length the slice may assume." - len(x), cap(x) - x[n] onde n é maior que len é out of range. Use append. - Append maior que cap modifica o array subjacente. - pkg/builtin/#append: "If it has sufficient capacity, the destination is resliced to accommodate the new elements. If it does not, a new underlying array will be allocated." - Effective Go. - Go Playground: https://play.golang.org/p/e8GWzyEEL8

Course Hive

Continue this lesson in the app

Install CourseHive on Android or iOS to keep learning while you move.

Related Courses

FAQs

Course Hive
Download CourseHive
Keep learning anywhere