arrays - Ruby - Enumerable::group_by 和空字符串
问题描述
group_by
我正在尝试使用如下方法在服务中的单个空键上对数组进行分组
...
def process(array)
if a_case
partition = method(:general_entity)
else
partition = method(:other_entity)
end
array.group_by(&partition)
end
def general_entity(_cells)
""
end
def other_entity(_cells)
...
您认为这种方法上的general_entity
方法可以安全使用吗?
如果您能分享您的想法或提出更好的方法,那就太好了:D