Attempting to learn Ruby using the new LearnStreet online tutorials.
Have attempted to get help via their Q&A system but it seems nobody answers them.
“Can you now implement the withdraw! method on account object, which
takes one parameter amount and reduces the balance by the specified
amount? After defining the method, go ahead and withdraw 100 dollars
from the account and check the balance.”
Is the question and I got the two hints of
” Hint 1 The code @balance = @balance – amount reduces the amount from
@balance.Hint 2 Then call the method withdraw! on the account object –
account.withdraw!(100). “
My attempt was
def
account.widthdraw!
@balance = @balance - amount
end
account.withdraw!(100)
Any ideas what I’m missing?
One step at a time:
“Can you now implement the withdraw! method on account object
which takes one parameter amount…
and reduces the balance by the specified amount?
After defining the method, go ahead and withdraw 100 dollars from the account and check the balance.”