Skip to content

Commit

Permalink
13-loops
Browse files Browse the repository at this point in the history
  • Loading branch information
Ruteski committed Mar 27, 2024
1 parent a1a8dd4 commit b6b7f71
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions 13-loops/loops.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package main

import (
"fmt"
)

// nao se usa range em struct

func main() {
i := 0

for i < 10 {
i++
fmt.Println("Incrementando i:", i)
//time.Sleep(time.Second)
}

fmt.Println("----------------")

for j := 0; j < 10; j++ {
fmt.Println("Incrementando j:", j)
//time.Sleep(time.Second)
}
fmt.Println("----------------")
nomes := [3]string{"Joao", "Davi", "Lucas"} // array
nomes2 := []string{"Joao", "Davi", "Lucas"} // slice

for indice, nome := range nomes {
fmt.Println("indice:", indice, "nome:", nome)
}

fmt.Println("----------------")
for _, nome := range nomes2 {
fmt.Println("nome:", nome)
}

fmt.Println("----------------")
for indice, letra := range "PALAVRA" {
fmt.Println(indice, " - código ASCII:", letra, " - valor:", string(letra))
}

fmt.Println("----------------")
usuario := map[string]string{
"nome": "Leonardo",
"sobrenome": "Silva",
}

for chave, valor := range usuario {
fmt.Println(chave, valor)
}

}

0 comments on commit b6b7f71

Please sign in to comment.