Instance Methodswift 6.0.1Swift

    next(upperBound:)

    Returns a random value that is less than the given upper bound.

    mutating func next<T>(upperBound: T) -> T where T : FixedWidthInteger, T : UnsignedInteger

    Parameters

    upperBound

    The upper bound for the randomly generated value. Must be non-zero.

    Returns

    A random value of T in the range 0..<upperBound. Every value in the range 0..<upperBound is equally likely to be returned.

    Use this method when you need random binary data to generate another value. If you need an integer value within a specific range, use the static random(in:using:) method on that integer type instead of this method.

    Other members in extension

    Instance members