What is the point of slice type in Go? -
i have read this still not aware of advantage of slice against array.so expecting in explain better , sure can :)
slices have lot of uses on arrays, several of other posters have mentioned.
- slices can operate in many ways pointers.  
- multiple slices can "point" same base array
 - slices passed reference, since slice pointer can used pass "arrays" around more efficiently since entire array doesn't need copied.
 
 - however, unlike pointers, slices provide additional buffer safety  
- slice underflows , overflows trigger exceptions, rather allowing unsafe ability access other areas of memory.
 - slices allow limit access areas of array. can extremely useful in working subsets.
 
 - the length of slice dynamically determined @ runtime, unlike arrays have sizes fixed @ compile time. also, slices can dynamically resized @ runtime.
 
Comments
Post a Comment