samedi 20 juin 2020

Dice roll and store results Ruby

So here's what I'm trying to do:

def nums

   nums = random number between 0...51, need 6 results. 
   the six results go into an array and are temporarily stored to be used in different method.
  
end

The next part will use this array to carry through a few mathematical functions. I already have that part ready, I'd just like to generate my own numbers.

What I tried:

def int_array
   nums = rand[6](0...51)
   nums = (0...51).rand(6)
   nums = (0...51, limit: 6)
   nums = [ rand(50), rand(50), rand(50), rand(50), rand(50), rand(50) ]
   nums = [ 6.times.rand(50) ]
   return nums
end

As you can see from the code above, I have absolutely no clue what I'm doing and nothing is working. Send help.




Aucun commentaire:

Enregistrer un commentaire