I need to check if the given both keys is present in hash. Checking is not the problem here but one of the keys may not be present and can return false. I need to delete only the keys that are present.
if model_changes.has_key?(name)
model_changes.delete(name)
end
if model_changes.has_key?(id)
model_changes.delete(id)
end
Instead of writing in two separate conditions is it possible to combine and delete the present key
Aucun commentaire:
Enregistrer un commentaire