sarthak wrote
I was trying to create a simple Bank Accounting system. I have the following code:
...
let Balance = b.Bal - amt;
let b.Bal = Balance;
...
But it is showing the following compilation error:
In BankAccount.jack (line 14): In subroutine AmountTransfer: Expected (
In BankAccount.jack (line 15): In subroutine AmountTransfer: Expected [ or =
What is the problem with the above code?
The problem is that Jack does not allow access to member variables using '.'. You need to write methods to read and write member variables:
let Balance = b.GetBalance() - amt;
do b.SetBalance(Balance);
[BTW, your assignments are backwards in your constructor.]
--Mark