Link Search Menu Expand Document

Random

Table of contents

  1. Random
    1. Random.random()
    2. Random.range(number: lowest, number: highest)
    3. Random.select(list)

Random

To make use of the Random module an import is required.

Note: This is not cryptographically secure and should not be used for such purposes.

import Random;

Random.random()

Return a random decimal between 0 and 1.

Random.random(); // 0.314
Random.random(); // 0.271

Random.range(number: lowest, number: highest)

Returns a random integer between the lowest and highest inputs where both are inclusive.

Random.range(1, 5); // 2
Random.range(1, 5); // 4
Random.range(0, 2); // 1

Random.select(list)

Returns a value randomly selected from the list.

Random.select([2, 4, 6]);  // 6
Random.select([2, 4, 6]);  // 2
Random.select(["a", "b", "c"]); // "c"

This site uses Just The Docs, with modifications.