lundi 1 août 2016

Ruby: How to assign .rand as value in hash within an array

So I have an array that contains 3 hashes. Each contains two keys and two corresponding values. I want all of those values to be a random number between 100 and 900. How do I write that? The ?? below is where I need the random numbers to go.

Peeps = [
    {
    name: "Buffy Summers",
    number: ??
    },
    {
    name: "Willow Rosenberg",
    number: ??
    },
    {
    name: "Xander Harris",
    number: ??
    }
]




Aucun commentaire:

Enregistrer un commentaire