From 5c195d849b90e2ad9574a2e15c37d2d13b474027 Mon Sep 17 00:00:00 2001 From: Rafael Fourquet Date: Thu, 8 Jun 2017 12:33:40 +0200 Subject: [PATCH] update doc (tkelman & ararslan) --- base/random.jl | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/base/random.jl b/base/random.jl index e3582f3ffe9c5..02bea3d8a2e2a 100644 --- a/base/random.jl +++ b/base/random.jl @@ -264,13 +264,7 @@ Pick a random element or array of random elements from the set of values specifi `S` defaults to [`Float64`](@ref). -!!! note - The complexity of `rand(rng, s::Union{Associative,AbstractSet})` - is linear in the length of `s`, unless an optimized method (with - constant complexity) is available (which is the case for `Dict`, - `Set` and `IntSet`). For more than a few calls, use `rand(rng, - collect(s))` instead (or `rand(rng, Dict(s))`, or `rand(rng, - Set(s))`). +# Examples ```julia-repl julia> rand(Int, 2) @@ -280,6 +274,14 @@ julia> rand(Int, 2) julia> rand(MersenneTwister(0), Dict(1=>2, 3=>4)) 1=>2 + +!!! note + The complexity of `rand(rng, s::Union{Associative,AbstractSet})` + is linear in the length of `s`, unless an optimized method with + constant complexity is available, which is the case for `Dict`, + `Set` and `IntSet`. For more than a few calls, use `rand(rng, + collect(s))` instead, or either `rand(rng, Dict(s))` or `rand(rng, + Set(s))` as appropriate. ``` """ @inline rand() = rand(GLOBAL_RNG, CloseOpen)