Logo

Programming-Idioms

  • Java
  • Go

Idiom #339 Clear a byte array

Set all the elements of the byte array a to zero

clear(a)

a is a slice
clear(a[:])

a is an array (but slices are more common)
import java.util.Arrays;
Arrays.fill(a, (byte)0);

a is a byte[]
Array.Fill(a, (byte)0);

New implementation...
< >
programming-idioms.org