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.
私は次のものを持っています:
array = ["John", "Mike", "Bob", "Mike", "Bob"]
出力を取得したい:
[["Mike", "Mike"], ["Bob", "Bob"], ["John"]]
これをRubyで行う方法は次のとおりです。
array.group_by{ |x| x }.values