mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 01:21:38 +08:00
04.4.1.md
This commit is contained in:
14
eBook/examples/chapter_4/presuffix.go
Normal file
14
eBook/examples/chapter_4/presuffix.go
Normal file
@@ -0,0 +1,14 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"strings"
|
||||
)
|
||||
|
||||
func main() {
|
||||
var str string = "This is an example of a string"
|
||||
|
||||
fmt.Printf("T/F? Does the string \"%s\" have prefix %s? ", str, "Th")
|
||||
fmt.Printf("%t\n", strings.HasPrefix(str, "Th"))
|
||||
}
|
||||
// Output: T/F? Does the string "This is an example of a string" have prefix Th? true
|
Reference in New Issue
Block a user