Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个数组,我想确保所有数字都在 1 到 6 之间。这是我的数组:
guess = [2, 5, 6, 8]
或类似的东西。用户输入序列。无论如何,我想要一种方法来检查它,如果数字不都在 1 到 6 之间,它就不会跳出循环。也可以简单点!
guess.all?{|i| (1..6).include?(i)}
guess.count{|i| i.between?(1,6)} == guess.size