RandomInRangeable

public protocol RandomInRangeable : Comparable

Indicates a type which can provide random values within a Range

Note

Many existing Swift classes support this format despite not deriving from a protocol
  • Returns a random value within the specified range.

    Declaration

    Swift

    static func random<RNG>(in range: ClosedRange<Self>, using generator: inout RNG) -> Self where RNG : RandomNumberGenerator

    Parameters

    range

    The range in which to create a random value. range must not be empty.

    Return Value

    A random value within the bounds of range.

  • Returns a random value within the specified range.

    Declaration

    Swift

    static func random<RNG>(in range: Range<Self>, using generator: inout RNG) -> Self where RNG : RandomNumberGenerator

    Parameters

    range

    The range in which to create a random value. range must not be empty.

    Return Value

    A random value within the bounds of range.