Go 슬라이스 비우기

Jmnote (토론 | 기여)님의 2024년 3월 15일 (금) 10:24 판 (새 문서: ==개요== ;Go 슬라이스 비우기 <syntaxhighlight lang='console'> package main import "fmt" func main() { nums := []int{10, 20, 30, 40, 50} fmt.Println(nums) // [10 20 30 40...)
(차이) ← 이전 판 | 최신판 (차이) | 다음 판 → (차이)

1 개요

Go 슬라이스 비우기
package main

import "fmt"

func main() {
	nums := []int{10, 20, 30, 40, 50}
	fmt.Println(nums) // [10 20 30 40 50]
	nums = nums[:0]   // Empty the slice
	fmt.Println(nums) // []
}

2 같이 보기

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