"Go 슬라이스 n번째 제거"의 두 판 사이의 차이

(새 문서: ==개요== ;Go 슬라이스 n번째 원소 제거 <syntaxhighlight lang='go' run> package main import "fmt" func main() { fruits := []string{"Alice", "Bob", "Carol", "David"} n :...)
 
 
(같은 사용자의 중간 판 3개는 보이지 않습니다)
1번째 줄: 1번째 줄:
==개요==
==개요==
;Go 슬라이스 n번째 제거
;Go 슬라이스 n번째 원소 제거
;Go 슬라이스 n번째 원소 제거


8번째 줄: 9번째 줄:


func main() {
func main() {
fruits := []string{"Alice", "Bob", "Carol", "David"}
fruits := []string{"A", "B", "C", "D"}
n := 2
n := 2
fruits = append(fruits[:n], fruits[n+1:]...)
fruits = append(fruits[:n], fruits[n+1:]...)
fmt.Println(fruits) // [Alice Bob David]
fmt.Println(fruits) // [A B D]
}
}
</syntaxhighlight>
</syntaxhighlight>
17번째 줄: 18번째 줄:
==같이 보기==
==같이 보기==
* [[Go 슬라이스]]
* [[Go 슬라이스]]
* [[Go 슬라이스 처음 n개 제거]]
* [[Go 슬라이스 마지막 n개 제거]]


[[분류: Go 슬라이스]]
[[분류: Go 슬라이스]]

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

1 개요[ | ]

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

import "fmt"

func main() {
	fruits := []string{"A", "B", "C", "D"}
	n := 2
	fruits = append(fruits[:n], fruits[n+1:]...)
	fmt.Println(fruits) // [A B D]
}

2 같이 보기[ | ]

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