Go 슬라이스 n번째 제거

Jmnote (토론 | 기여)님의 2024년 3월 15일 (금) 10:10 판 (새 문서: ==개요== ;Go 슬라이스 n번째 원소 제거 <syntaxhighlight lang='go' run> package main import "fmt" func main() { fruits := []string{"Alice", "Bob", "Carol", "David"} n :...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

Go 슬라이스 n번째 원소 제거
package main

import "fmt"

func main() {
	fruits := []string{"Alice", "Bob", "Carol", "David"}
	n := 2
	fruits = append(fruits[:n], fruits[n+1:]...)
	fmt.Println(fruits) // [Alice Bob David]
}

2 같이 보기

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