Ruby on Rails
PhpArray_diff_ukey

Much as with PhpArray_diff_uassoc we’ll just override eql? and then use the same technique from PhpArray_diff_key


class CustomString < String
  def eql?(b)
    #This is the user defined function
    self == b
  end
end

hash1 = {CustomString.new('blue')  => 1, CustomString.new('red')  => 2, CustomString.new('green')  => 3, CustomString.new('purple') => 4}
hash2 = {CustomString.new('green') => 5, CustomString.new('blue') => 6, CustomString.new('yellow') => 7, CustomString.new('cyan')  => 8}
hash3 = {}
(hash1.keys - hash2.keys).each do |key|
  hash3[key] = hash1[key]
end