Does Go have functions to fill an array with a specified value, like
memset in C?
With memset, I can define only one array, and reuse it for 10000
times.
Maybe it's not important in general programming, but the problem often limit memory usage.
On 25 May 2010 12:25, Lambda <steph...@gmail.com> wrote:With memset, I can define only one array, and reuse it for 10000
times.
With a for loop, too. Yes -- you may not get the very best of
optimised behaviour; but on the other hand, in Go, the loop
for i, _ in range byteArray { byteArray[i] = 0 }
On Tue, May 25, 2010 at 7:45 AM, chris dollin
for i, _ in range byteArray { byteArray[i] = 0 }
Blasphemer!for i := range byteArray { byteArray[i] = 0 }
Of course, this particular loop would be useless, since the same thing happens when you dovar byteArray [10000]byteorbyteSlice := make([]byte, 10000)
s0 := bytes.Repeat([]byte{ 10 }, 100)