cities with a for loop example
This commit is contained in:
parent
4274c71f77
commit
99534f58cd
3 changed files with 20 additions and 0 deletions
8
for_range/demo1.go
Normal file
8
for_range/demo1.go
Normal file
|
@ -0,0 +1,8 @@
|
||||||
|
package range
|
||||||
|
|
||||||
|
func Demo1() {
|
||||||
|
cities := []string("Ankara", "İstanbul", "İzmir")
|
||||||
|
for i := 0; i < len(cities); i++ {
|
||||||
|
fmt.Println(cities[i])
|
||||||
|
}
|
||||||
|
}
|
2
main.go
2
main.go
|
@ -7,6 +7,7 @@ import (
|
||||||
"golesson/functions"
|
"golesson/functions"
|
||||||
"golesson/loops"
|
"golesson/loops"
|
||||||
"golesson/maps"
|
"golesson/maps"
|
||||||
|
for_range "golesson/range"
|
||||||
"golesson/slices"
|
"golesson/slices"
|
||||||
"golesson/variables"
|
"golesson/variables"
|
||||||
)
|
)
|
||||||
|
@ -39,4 +40,5 @@ func main() {
|
||||||
fmt.Println(functions.AddVariadic(numbers_main...))
|
fmt.Println(functions.AddVariadic(numbers_main...))
|
||||||
|
|
||||||
maps.Demo1()
|
maps.Demo1()
|
||||||
|
for_range.Demo1()
|
||||||
}
|
}
|
||||||
|
|
10
range/demo1.go
Normal file
10
range/demo1.go
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
package for_range
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func Demo1() {
|
||||||
|
cities := []string{"Ankara", "İstanbul", "İzmir"}
|
||||||
|
for i := 0; i < len(cities); i++ {
|
||||||
|
fmt.Println(cities[i])
|
||||||
|
}
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue