"Go Index()"의 두 판 사이의 차이

13번째 줄: 13번째 줄:


func main() {
func main() {
fmt.Println(strings.Index("hello world", "e"))
fmt.Println(strings.Index("hello world", "h")) // 0
fmt.Println(strings.Index("hello world", "l"))
fmt.Println(strings.Index("hello world", "e")) // 1
fmt.Println(strings.Index("hello world", "ll"))
fmt.Println(strings.Index("hello world", "ll")) // 2
}
}
</syntaxhighlight>
</syntaxhighlight>

2023년 1월 19일 (목) 15:45 판

1 개요

Go Index()
Go 문자열 Index()
Go strings.Index()
package main

import (
	"fmt"
	"strings"
)

func main() {
	fmt.Println(strings.Index("hello world", "h"))  // 0
	fmt.Println(strings.Index("hello world", "e"))  // 1
	fmt.Println(strings.Index("hello world", "ll")) // 2
}

2 같이 보기

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