I have an array of Mortgage objects
class Mortgage
attr_accessor :rate, :deposit
def initialize(deposit, rate)
@deposit = deposit
@rate = rate
end
end
I'd like to reject any mortgage which has a higher rate than another mortgage with the same deposit.
For example, Imagine the following array of mortgages
Mortgage 1, :rate => 3, :deposit => 20
Mortgage 2, :rate => 5, :deposit => 20
Mortgage 3, :rate => 7, :deposit => 30
The method should reject mortgage 2.