Ciklet (for)

for

package main

import (
    "fmt"
)

func main() {
    sum := 0
    for i := 0; i < 100; i++ {
        sum += i
    }
    fmt.Println(sum)
}

https://play.golang.org/p/iWDx5k3TGZ8

break

package main

import (
    "fmt"
)

func main() {
    i := 0
    for {
        if i == 10 {
            break
        }
        fmt.Println("Vlera e i është:", i)
        i++
    }
    fmt.Println("Dalja nga cikli")
}

https://play.golang.org/p/hkZAYJ_rVtN

continue

package main

import (
    "fmt"
)

func main() {
    for i := 1; i <= 5; i++ {
        if i == 3 {
            continue
        }
        fmt.Println(i)
    }
}

https://play.golang.org/p/5yyYPx2XEYs

All Rights Reserved Theme by 404 THEME.