break
and continue
statements can be use with label in Go, similar
to goto
statement. It is optional. Scope of labels are limited to
the function and does not conflict with variable name, as it live in
separate space. break and continue with label is only used in for,
switch and select statements.
|
|
Output:
i=0, j=0
Above example breaks outer loop.
|
|
Output:
i=0, j=0
i=1, j=0
i=2, j=0
continue with label continues the iteration of variables.