lo icon indicating copy to clipboard operation
lo copied to clipboard

Helper to fill slice to specific size (if needed)

Open renom opened this issue 2 years ago • 0 comments

Call: HelperFunc([]string{"a", "a"}, "b", 8) Result: []string{"a", "a", "b", "b", "b", "b", "b", "b"}

Call: HelperFunc([]string{"a", "a", "a", "a", "a", "a", "a", "a"}, "b", 8) Result: []string{"a", "a", "a", "a", "a", "a", "a", "a"}

Call: HelperFunc([]string{"a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a"}, "b", 8) Result: []string{"a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a", "a"}

Thus the helper does not remove data, just fill the slice with the value if its size is less than the required size.

renom avatar Jun 05 '23 10:06 renom