You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@barryz, the proposed "right" version will panic due to out-of-range access.
The capacity pre-allocation should be used with append without direct index assignment.
Initial demo does the length-based pre-allocation with index assignment.
Article: 6-tips-and-tricks/1-tips-and-tricks.md
Section: Preallocate slices if the length is known
Wrong demo:
Right demo:
The text was updated successfully, but these errors were encountered: