refactor: loops 02-path-searcher
This commit is contained in:
@ -14,8 +14,6 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
const notFound = -1
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
// Get and split the PATH environment variable
|
// Get and split the PATH environment variable
|
||||||
|
|
||||||
@ -34,7 +32,7 @@ func main() {
|
|||||||
for i, w := range words {
|
for i, w := range words {
|
||||||
q, w = strings.ToLower(q), strings.ToLower(w)
|
q, w = strings.ToLower(q), strings.ToLower(w)
|
||||||
|
|
||||||
if strings.Index(w, q) != notFound {
|
if strings.Contains(w, q) {
|
||||||
fmt.Printf("#%-2d: %q\n", i+1, w)
|
fmt.Printf("#%-2d: %q\n", i+1, w)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user