mercredi 10 août 2016

How to exclude samples that are already sampled before on rubyonrails

First, I am beginner as a developer using ruby-on-rails. I am using blahblah.sample(x) to get (x) samples from blahblah. What i want to do is, I am using a loop to put several different numbers in an array. I will use the sample method to get (x) numbers. Here is the point I don't want to put the same number many times in the array. I know that if i put the random numbers and use uniq method this problem will be solved, but I want to exclude the number that i have in the array before I put it in the array. How can I solve this problem? I want to recognize that I have the number in the array or not before I put the number inside the array.

What I am eventually trying to do is When I am getting 10 sample of users to analyze their data. So I don't want to analyze the user that is analyzed already. I want to recognize if they are analyzed or not.




Aucun commentaire:

Enregistrer un commentaire