Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add rand(::String) #22224

Merged
merged 7 commits into from
Jun 15, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
warn about linear complexity for AbstractString (stevengj)
  • Loading branch information
rfourquet committed Jun 13, 2017
commit 5e827e9985e38939b5c0d8ef7f4c5a8ba800c920
5 changes: 5 additions & 0 deletions base/random.jl
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,11 @@ julia> rand(MersenneTwister(0), Dict(1=>2, 3=>4))
`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.

!!! note
the complexity of `rand(rng, s::AbstractString)` is linear
in the length of `s` if `s` is not of type `String`. If called more
than a few times, you should use `rand(rng, collect(s))` instead.
"""
@inline rand() = rand(GLOBAL_RNG, CloseOpen)
@inline rand(T::Type) = rand(GLOBAL_RNG, T)
Expand Down