mirror of https://github.com/golang/go.git
math/rand: add example for Intn func
This commit is contained in:
parent
fe05bddecb
commit
2adfcd2d5a
|
|
@ -142,8 +142,9 @@ func ExampleShuffle_slicesInUnison() {
|
|||
}
|
||||
|
||||
func ExampleIntn() {
|
||||
// 86 - arbitrary value just for sake of example,
|
||||
// so people don't blindly hard-code this value into program use meaningful one.
|
||||
// Seeding with the same value results in the same random sequence each run.
|
||||
// For different numbers, seed with a different value, such as
|
||||
// time.Now().UnixNano(), which yields a constantly-changing number.
|
||||
rand.Seed(86)
|
||||
fmt.Println(rand.Intn(100))
|
||||
fmt.Println(rand.Intn(100))
|
||||
|
|
|
|||
Loading…
Reference in New Issue