https://play.golang.org/p/Z9nUFsC453B
if true
If what is true?
if true
means that code in condition will always execute.
It could be used for infinity loops :
package main
import (
"fmt"
)
func main() {
i := 0
for true { // always true because true is constant
if i > 10 {
break
}
fmt.Println(i)
i++
}
}
https://play.golang.org/p/gp4oczexZwF
but in condition it’s redundant, just remove condition.
Thank you
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.