Skip to content

Instantly share code, notes, and snippets.

@darxtrix
Last active April 20, 2018 17:52
Show Gist options
  • Save darxtrix/375fa0c4cc8c0858f2b5f683783ec174 to your computer and use it in GitHub Desktop.
Save darxtrix/375fa0c4cc8c0858f2b5f683783ec174 to your computer and use it in GitHub Desktop.
#golang #basic
  • An array has a fixed size where as the slices can be of dynamic types
  • Array slices are references that are easier to pass to the functions as compared to pointers. (https://stackoverflow.com/questions/2439453/using-a-pointer-to-array)
  • Go arrays are full objects, when we pass them to functions they are fully copied. Its not like in case of C, i.e pass by reference.
  • The type specification of a go slice is []T where the T is the type of the slice.
letters := []string{"a", "b", "c", "d"}

func make([]T, len, cap) []T
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment