FOR Loop

This lesson discusses for loops, including, for loop without a statement using examples and their use as an alternative to the while loop in Go

Comparison with Other Languages

Go has only one looping construct, the for loop. The basic for loop looks as it does in C or Java, except that the ( ) are gone (they are not even optional) and the { } are required. As in C or Java, you can leave the pre and post statements empty.

for Loop Syntax

  • Example of a for loop:

Get hands-on with 1200+ tech skills courses.