Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and the Yahoo Answers website is now in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.
Trending News
Ruby !! Method withdraw Help?
I just try to write this code but every time get below message.
Error Message: <Internal error: TypeError: FUNCTION_TABLE[HEAP[((HEAP[(f & (intermediate value))] + 4) & (intermediate value))]] is not a function>
I write this code in Ruby compiler :
def account.withdraw
@balance=@balance-amount
end
account.withdraw!(100)
Instructions
How to access the instance variable, but how do we change the value? This is where variable assignment comes in. How can i implement the withdraw! method on account object, which takes one parameter amount and reduces the balance by the specified amount? After defining the method, how can i ahead and withdraw 100 dollars from the account and check the balance.
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)
1 Answer
- 8 years agoFavorite Answer
Lets Try it. This is the answers from this question.
def account.withdraw!(account)
@balance = @balance - account
end
account.withdraw!(100)