Ruby: What is a simple way of searching for certain criteria in an array? -
I have an array that I want to make sure that all numbers are between 1 and 6. This is my array:
Estimate = [2, 5, 6, 8] Or something like this, the user inputs the sequence, I Want a way to check, and if the number is not between 1 and 6, then it does not come out of the loop. And it can also be simple!
estimate.All? {| I (1..6). Is it included? (I)}
Comments
Post a Comment