Skip to content

Commit 96431e0

Browse files
committed
Minor fixes in loops
1 parent fd3b7cc commit 96431e0

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

src/routes/(examples)/04-loops/content.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Loops
22

3-
Tact does not support traditional `for` loops, but its loop statements are equivalent and can easily implement the same things.
3+
Tact does not support traditional `for` loops, but its loop statements are equivalent and can easily implement the same things. Also note that Tact does not support `break` and `continue` statements in loops like some languages.
44

55
The `repeat` loop statement input number must fit within an `int32`, otherwise an exception will be thrown.
66

src/routes/(examples)/04-loops/contract.tact

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ contract Loops with Deployable {
77
receive("loop1") {
88
let sum: Int = 0;
99
let i: Int = 0;
10-
repeat (10) {
10+
repeat (10) { // repeat exactly 10 times
1111
i = i + 1;
1212
sum = sum + i;
1313
}
@@ -17,7 +17,7 @@ contract Loops with Deployable {
1717
receive("loop2") {
1818
let sum: Int = 0;
1919
let i: Int = 0;
20-
while (i < 10) {
20+
while (i < 10) { // loop while a condition is true
2121
i = i + 1;
2222
sum = sum + i;
2323
}
@@ -27,7 +27,7 @@ contract Loops with Deployable {
2727
receive("loop3") {
2828
let sum: Int = 0;
2929
let i: Int = 0;
30-
do {
30+
do { // loop until a condition is true
3131
i = i + 1;
3232
sum = sum + i;
3333
} until (i >= 10);
@@ -36,7 +36,7 @@ contract Loops with Deployable {
3636

3737
receive("out of gas") {
3838
let i: Int = 0;
39-
while (i < pow(10, 6)) {
39+
while (i < pow(10, 6)) { // 1 million iterations is too much
4040
i = i + 1;
4141
}
4242
dump(i);

0 commit comments

Comments
 (0)