Skip to content

Randomness

This content is not available in your language yet.

This page lists examples of working with random numbers, uncertainty and randomness in general.

How to generate a random number

// Declare a variable to store the random number
let number: Int;
// Generate a new random number, which is an unsigned 256-bit integer
number = randomInt();
// Generate a random number between 1 and 12
number = random(1, 12);