crand
crand copied to clipboard
For is Go's while loop
https://tour.golang.org/flowcontrol/3
Looks like you use for do := true; do; do = condition {}.
You can simplify this to for condition {}
I want to check the condition after each iteration. I couldn't find a more idiomatic way to accomplish that.
Ah, I meant to say you could do:
Rand(buf)
for cond {
Rand(buf)
}
Feels a little more obvious about what the loop is doing.
Why not do something like what math/rand does:
https://golang.org/src/math/rand/rand.go?s=2478:2514#L69
seems like the loop you described is exactly what math.Rand does, I'll refactor next time I have a little bit of time. Thanks.