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.
我有字符串 s1,s2,s3,s4 并且我想通过所有比较来做所有事情,所以想比较 s1 和 s2,s3,s4 和 s2 和 s3,s4 和 s3 和 s4,最好的方法是什么.
类似于 for 循环的东西?
谢谢
请参阅 RubyArray#combination方法:
Array#combination
arr = [1, 2, 3, 4] arr.combination(2) do |x,y| # Compare X to Y end