Reputation: 1243
I was wondering if this can be improved upon.
I have two arrays: links and archived_releases.
links
contains strings, that might appear in the :url key
of an archived_releases
entry.
This didn't work:
links.delete_if { |link|
archived_releases.count > archived_releases.delete_if{ |release| release[:url] == link }.count
}
So I came up with this:
links.delete_if { |link|
archived_releases.count > archived_releases.delete_if{ |release| release[:url] == link }.count
}
Upvotes: 0
Views: 112
Reputation: 32748
I would first pull out the archived_releases
entries you want to quickly compare and then you can just use a quick include?
check. Something like:
urls = archived_releases.collect { |ar| ar[:url] }
links.delete_if { |link| urls.include?(link) }
Upvotes: 1