blob: 4f533ed22bc0d883307f52782d01a10c1fe40ccb [file] [log] [blame] [edit]
//go:build go1.24
package splitseq
import (
"bytes"
"strings"
)
func _() {
for _, line := range strings.Split("", "") { // want "Ranging over SplitSeq is more efficient"
println(line)
}
for i, line := range strings.Split("", "") { // nope: uses index var
println(i, line)
}
for i, _ := range strings.Split("", "") { // nope: uses index var
println(i)
}
for i := range strings.Split("", "") { // nope: uses index var
println(i)
}
for _ = range strings.Split("", "") { // want "Ranging over SplitSeq is more efficient"
}
for range strings.Split("", "") { // want "Ranging over SplitSeq is more efficient"
}
for range bytes.Split(nil, nil) { // want "Ranging over SplitSeq is more efficient"
}
{
lines := strings.Split("", "") // want "Ranging over SplitSeq is more efficient"
for _, line := range lines {
println(line)
}
}
{
lines := strings.Split("", "") // nope: lines is used not just by range
for _, line := range lines {
println(line)
}
println(lines)
}
}