cap*_*rad 3 ruby ruby-on-rails
我知道如果你有一个array并引用它,array.uniq因为它将返回没有任何重复.
但是在这种情况下它是一个对象数组(正确的红宝石说话吗?).我希望每次调用都进入@calls数组,除非它与数组中call.from已存在的call_formatted对象相同.
如果数组中没有其他对象具有相同的call.from值,我如何有条件地将这些对象放在数组中?
calls_raw.each do |call|
call_formatted = {
:date => date,
:time => time,
:from => call.from,
:duration => call.duration,
:recording => recording,
}
@calls << call_formatted
end
Run Code Online (Sandbox Code Playgroud)