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

10번째 줄: 10번째 줄:


func main() {
func main() {
slice := []string{"Alice", "Bob", "Carol", "David", "Eve", "Frank", "Grace"}
students := []string{"Alice", "Bob", "Carol", "David", "Eve"}
slice = slice[3:len(slice)]
fmt.Println(slice)
}
</syntaxhighlight>
<syntaxhighlight lang='go' run>
package main
 
import "fmt"
 
func main() {
slice := []string{"Alice", "Bob", "Carol", "David", "Eve", "Frank", "Grace"}
n := 3
n := 3
slice = slice[len(slice)-1-n:]
students = students[n:len(students)]
fmt.Println(slice)
fmt.Println(students) // [David Eve]
}
}
</syntaxhighlight>
</syntaxhighlight>



2024년 3월 15일 (금) 10:14 판

1 개요

Go 슬라이스 처음 n개 제거
Go 슬라이스 처음 n개 원소 제거
Go 슬라이스 처음 원소 n개 제거
package main

import "fmt"

func main() {
	students := []string{"Alice", "Bob", "Carol", "David", "Eve"}
	n := 3
	students = students[n:len(students)]
	fmt.Println(students) // [David Eve]
}

2 같이 보기

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