I am new to Go and very confused with one of the sample codes in the tutorial. Here is the code and its output:
package main
import (
"fmt"
"math"
)
func pow(x, n, lim float64) float64 {
if v := math.Pow(x, n); v < lim {
return v
} else {
fmt.Printf("%g >= %g
", v, lim)
}
return lim
}
func main() {
fmt.Println(pow(3, 3, 10), pow(4, 3, 20))
}
When I run it, the output of this code is:
27 >= 10
64 >= 20
10 20
Which is quite strange to me! I expect this output:
27 >= 10
10
64 >= 20
20
Can someone please help me to understand what is going on with Println in this code?