There are several types of golang loops

Release: 2020-01-15 10:22:06
Original
2628 people have browsed it

There are several types of golang loops

Go languageprovides the following types of loop processing statements:

Loop types
Description
for loop Repeated execution of statement blocks
Loop nesting Nest one or more for loops within a for loop

for loop:

The for loop is a loop control Structure that can execute a specified number of loops.

Syntax

There are 3 forms of For loop in Go language, only one of which uses semicolon.

Same as for in C language:

for init; condition; post { }
Copy after login

Same as while in C:

for condition { }
Copy after login

Same as for(;;) in C:

for { }
Copy after login

Loop Nesting

The Go language allows users to use loops within loops. Next we will introduce the use of nested loops.

Grammar

The following is the format of nested loops in Go language:

for [condition | ( init; condition; increment ) | Range] { for [condition | ( init; condition; increment ) | Range] { statement(s); } statement(s); }
Copy after login

For more golang knowledge, please pay attention to thegolang tutorialcolumn on the PHP Chinese website.

The above is the detailed content of There are several types of golang loops. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!