相关疑难解决方法(0)

如何计算Ruby数组中的重复元素

我有一个排序数组:

[
  'FATAL <error title="Request timed out.">',
  'FATAL <error title="Request timed out.">',
  'FATAL <error title="There is insufficient system memory to run this query.">'
]
Run Code Online (Sandbox Code Playgroud)

我想得到这样的东西,但它不一定是哈希:

[
  {:error => 'FATAL <error title="Request timed out.">', :count => 2},
  {:error => 'FATAL <error title="There is insufficient system memory to run this query.">', :count => 1}
]
Run Code Online (Sandbox Code Playgroud)

ruby arrays

67
推荐指数
8
解决办法
6万
查看次数

标签 统计

arrays ×1

ruby ×1