Hi all,
I have written small code for testing purpose. But it is giving error. But not sure why?
could someone help me on this.
class JointAccount (val balance: Long) {
** | def displayBalance = println(balance)**
** | def withDrawl(amt: Int) = {**
** | balance -=amt;**
** | }**
** | def deposit(amt: Int) = {**
** | balance -=amt;**
** | }**
Thanks in advance.
Howdy! A couple of things:
- Could you edit your code to make it readable? Remove the
**
s around it and the |
at the front of the lines, and put triple-backticks (```) on a line by themselves before and after the code. That will make it display as code, instead of being hard-to-read as it now is.
- What error are you getting? There are many possible problems, so it makes it much easier for folks to help you if you say exactly what the error is.
I would guess that the main issue is that balance
is a val
and since you are trying to mutate it, it needs to be a var
. You are probably getting error messages about -=
not being a member of Long
.
Hi All,
Thanks issue got fixed