"Go 슬라이스 처음 n개 남기고 제거"의 두 판 사이의 차이

 
10번째 줄: 10번째 줄:


func main() {
func main() {
students := []string{"Alice", "Bob", "Carol", "David", "Eve"}
students := []string{"A", "B", "C", "D", "E"}
n := 3
n := 3
students = students[:n]
students = students[:n]
fmt.Println(students) // [Alice Bob Carol]
fmt.Println(students) // [A B C]
}
}
</syntaxhighlight>
</syntaxhighlight>

2024년 4월 28일 (일) 13:57 기준 최신판

1 개요[ | ]

Go 슬라이스 처음 n개 남기기
Go 슬라이스 처음 n개 원소 남기기
Go 슬라이스 처음 원소 n개 남기기
package main

import "fmt"

func main() {
	students := []string{"A", "B", "C", "D", "E"}
	n := 3
	students = students[:n]
	fmt.Println(students) // [A B C]
}

2 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}