Skip to content

FR: implement rand() for tuple types. #50236

Closed
@gafter

Description

It would be nice to be able to generate, for example, a random value of type Tuple{Int, Bool} without having to implement it myself. Something like the following:

function Random.rand(rng::AbstractRNG, ::Type{A}) where {A <: Tuple}
    return ((Random.rand(rng, a) for a in A.parameters)...,)
end

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    featureIndicates new feature / enhancement requestsrandomnessRandom number generation and the Random stdlib

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions