Why does Julia say randstring() doesn't exist?

I was looking at string functions in the Julia documentation window in Atom and it mentioned randstring(). So I tried it and Julia says it doesn’t exist. In fact a lot or string functions it mentioned don’t seem to be there:
ERROR: UndefVarError: randstring not defined

It is even cited online as per below. What gives? Why are functions in the docs not there?

Try using Random:

julia> randstring
ERROR: UndefVarError: randstring not defined

julia> using Random

julia> randstring
randstring (generic function with 8 methods)

help?> randstring
search: randstring

  randstring([rng=GLOBAL_RNG], [chars], [len=8])

  Create a random string of length len, consisting of characters from chars, which defaults to the set of upper- and lower-case letters
  and the digits 0-9. The optional rng argument specifies a random number generator, see Random Numbers.

  Examples
  ≡≡≡≡≡≡≡≡≡≡

  julia> Random.seed!(3); randstring()
  "Y7m62wOj"

  julia> randstring(MersenneTwister(3), 'a':'z', 6)
  "ocucay"

  julia> randstring("ACGT")
  "ATTTGCGT"

  │ Note
  │
  │  chars can be any collection of characters, of type Char or UInt8 (more efficient), provided rand can randomly pick characters
  │  from it.

2 Likes

I don’t know what that website is, but the official documentation is at Julia Documentation · The Julia Language. In particular, you’d find randstring at Random Numbers · The Julia Language, which is part of the Random standard library, so you need to load it first:

julia> using Random

julia> randstring()
"RvR7CYqB"
4 Likes

Why does that function exist? It seems unusually specific for something as simple as join(rand('a':'z', 8)).

1 Like

For convenience I imagine. But that goes for most functions.

All the blog entries in that website are from 2015, way before julia v1.0.