package main
import "fmt"
func main() {
foods := [3]string{"potato","pizza", "pasta"}
for _, food := range food{
fmt.Println(food)
}
for i:=0; i<len(foods); i++{
fmt.Println(foods[i])
}
}
package main
import "fmt"
func main() {
foods := []string{"potato","pizza", "pasta"}
for _, food := range food{
fmt.Println(food)
}
for i:=0; i<len(foods); i++{
fmt.Println(foods[i])
}
}
package main
import "fmt"
func main() {
foods := []string{"potato","pizza", "pasta"}
fmt.Printf("%v\n", foods)
foodsNew := append(foods, "tomato") //foods의 복사본
foods = append(foods, "tomato") // 업데이트
fmt.Printf("%v\n", foods)
}
https://go.dev/play/p/HH8M0nHf8sI
강의 출처 : 노마드코더(https://nomadcoders.co)
[Nomad Coin] Tour of Go - #3.6 Structs (0) | 2022.07.11 |
---|---|
[Nomad Coin] Tour of Go - #3.5 Pointers (0) | 2022.07.10 |
[Nomad Coin] Tour of Go - #3.3 fmt (0) | 2022.07.10 |
[Nomad Coin] Tour of Go - #3.2 functions (0) | 2022.07.10 |
[Nomad Coin] Tour of Go - #3.1 Variables in Go (0) | 2022.07.10 |
댓글 영역