Document for Julia 1.0.3 for rand! confuses me

Look at the section for rand!
in Random Numbers · The Julia Language

Why is the following “rng = MersenneTwister(1234);” giving me an error?

$ julia
               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.0.3 (2018-12-18)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> rng = MersenneTwister(1234);
ERROR: UndefVarError: MersenneTwister not defined
Stacktrace:
 [1] top-level scope at none:0

The documentation you link is for the Random standard library. You need using Random to access these functions.

The documentation should mention the code
“using Random” at the very start just in case newbies reads it.

1 Like

Please make a pull request. This is open source thus everyone can contribute.

4 Likes