notexOPENOverview
Notex/Languages/The Condition-Only for Statement
02.07LESSON 07 OF 19 · 1 MIN READ

The Condition-Only for Statement

Always free to read

When you leave off both the initialization and the increment in a for statement, do not include the semicolons. (If you do, go fmt will remove them.) That leaves a for statement that functions like the while statements found in C, Java, JavaScript, Python, Ruby, and many other languages. It looks like Example 3-9.

Example 3-9. A condition-only for statement

i := 1
for i < 100 {
        fmt.Println(i)
        i = i * 2
}
Progress is saved on this device.
KEEP EXPLORING

One note leads to another.

Back to the library →
⌕
Search across the entire library ⌘ K