While implementing a new method called debit that decrements the @balance by the given amount by
class Account
def deposit(amount)
@balance = amount
end
def balance
@balance
end
def debit(amount)
@balance -= amount
end
end
class Teller
def initialize(cash_slot)
@cash_slot = cash_slot
end
def withdraw_from(account, amount)
account.debit(amount)
@cash_slot.dispense(amount)
end
end
error:
undefined method `-' for nil:NilClass (NoMethodError)
./lib/sample_bank.rb:17:in `debit'
./lib/sample_bank.rb:40:in `withdraw_from'
./lib/sample_bank.rb:66:in `block in <top (required)>'
./features/support/world_extensions.rb:8:in `withdraw_from''
Did, i got mistakes somewhere else. can you explain me about that.
|