1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
class
Calcuator
{
var
a:
Int
= 1;
b:
= 1;
sum:
{
get
{
return
a + b
}
set
(val){
b = val - a
}
}
}
let
cal =
();
print
(cal.sum)
//2
cal.sum = 5
(cal.b)
//4
|
{
b = newValue - a
}
|