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

**URL:** <https://discourse.julialang.org/t/why-does-julia-say-randstring-doesnt-exist/65704>\
**Category:** New to Julia\
**Created:** [August 2, 2021, 11:05pm UTC](https://discourse.julialang.org/t/why-does-julia-say-randstring-doesnt-exist/65704 "2021-08-02T23:05:17Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![cybervigilante](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cybervigilante/32/26687_2.png) [@cybervigilante](https://discourse.julialang.org/u/cybervigilante)\
**Post date:** [August 2, 2021, 11:05pm UTC](https://discourse.julialang.org/t/why-does-julia-say-randstring-doesnt-exist/65704/1 "2021-08-02T23:05:17Z")

</div>

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?

> **[randstring » Julia Functions](http://www.jlhub.com/julia/manual/en/function/randstring)**
>
> Learn Julia with our free tutorials and guides

---

<div class="post-metadata">

**Author:** ![Jeff\_Emanuel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jeff_emanuel/32/15440_2.png) [@Jeff\_Emanuel](https://discourse.julialang.org/u/Jeff_Emanuel)\
**Post date:** [August 2, 2021, 11:08pm UTC](https://discourse.julialang.org/t/why-does-julia-say-randstring-doesnt-exist/65704/2 "2021-08-02T23:08:59Z")

</div>

Try `using Random`:

```julia
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.

```

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [August 2, 2021, 11:10pm UTC](https://discourse.julialang.org/t/why-does-julia-say-randstring-doesnt-exist/65704/3 "2021-08-02T23:10:06Z")

</div>

I don’t know what that website is, but the official documentation is at [Julia Documentation · The Julia Language](https://docs.julialang.org/en/v1/). In particular, you’d find `randstring` at [Random Numbers · The Julia Language](https://docs.julialang.org/en/v1/stdlib/Random/#Random.randstring), which is part of the `Random` standard library, so you need to load it first:

```julia
julia> using Random

julia> randstring()
"RvR7CYqB"

```

---

<div class="post-metadata">

**Author:** ![jzr](https://avatars.discourse-cdn.com/v4/letter/j/eb9ed0/32.png) [@jzr](https://discourse.julialang.org/u/jzr)\
**Post date:** [August 2, 2021, 11:12pm UTC](https://discourse.julialang.org/t/why-does-julia-say-randstring-doesnt-exist/65704/4 "2021-08-02T23:12:52Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![gbaraldi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gbaraldi/32/22101_2.png) [@gbaraldi](https://discourse.julialang.org/u/gbaraldi)\
**Post date:** [August 2, 2021, 11:28pm UTC](https://discourse.julialang.org/t/why-does-julia-say-randstring-doesnt-exist/65704/5 "2021-08-02T23:28:34Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![aramirezreyes](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/aramirezreyes/32/42573_2.png) [@aramirezreyes](https://discourse.julialang.org/u/aramirezreyes)\
**Post date:** [August 3, 2021, 12:31am UTC](https://discourse.julialang.org/t/why-does-julia-say-randstring-doesnt-exist/65704/6 "2021-08-03T00:31:27Z")

</div>

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