MCPcopy Create free account
hub / github.com/goinaction/code / CountWords

Function CountWords

chapter3/words/count.go:8–11  ·  view source on GitHub ↗

CountWords counts the number of words in the specified string and returns the count.

(text string)

Source from the content-addressed store, hash-verified

6// CountWords counts the number of words in the specified
7// string and returns the count.
8func CountWords(text string) (count int) {
9 count = len(strings.Fields(text))
10 return
11}

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected