forked from tact-lang/tact
-
Notifications
You must be signed in to change notification settings - Fork 0
/
underscore-variable.tact
57 lines (50 loc) · 1.11 KB
/
underscore-variable.tact
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
contract UnderscoreVariableTestContract {
something: Int;
init() {
self.something = 0;
}
receive() {
// Nothing to do
}
fun increaseSomething(): Int {
self.something += 1;
return 123;
}
get fun test1(): Int {
try {
nativeThrowIf(1, true);
} catch (_) {
return 0;
}
return 1;
}
get fun test2(): Int {
let m: map<Int, Int> = emptyMap();
m.set(1, 2);
m.set(2, 4);
m.set(3, 6);
let x: Int = 0;
foreach (_, v in m) {
x += v;
}
return x;
}
get fun test3(): Int {
let m: map<Int, Int> = emptyMap();
m.set(1, 2);
m.set(2, 4);
m.set(3, 6);
let x: Int = 0;
foreach (k, _ in m) {
x += k;
}
return x;
}
get fun test4(): Int {
let _: Int = self.increaseSomething();
let _: Int = self.increaseSomething();
let _ = self.increaseSomething();
let _ = self.increaseSomething();
return self.something;
}
}