Sunday, 30 August 2015

Advanced Go: Slices

A slice points to an array of values and also includes a length.

[]T is a slice with elements of type T.


Slicing slices

Slices can be re-sliced, creating a new slice value that points to the same array.
The expression
s[lo:hi]
evaluates to a slice of the elements from lo through hi-1, inclusive. Thus
s[lo:lo]
is empty and
s[lo:lo+1]
has one element.

Do comment, if it worked/Not worked for you.

No comments:

Post a Comment