Source file tour/flowcontrol/if-with-a-short-statement.go

     1  //go:build OMIT
     2  
     3  package main
     4  
     5  import (
     6  	"fmt"
     7  	"math"
     8  )
     9  
    10  func pow(x, n, lim float64) float64 {
    11  	if v := math.Pow(x, n); v < lim {
    12  		return v
    13  	}
    14  	return lim
    15  }
    16  
    17  func main() {
    18  	fmt.Println(
    19  		pow(3, 2, 10),
    20  		pow(3, 3, 20),
    21  	)
    22  }
    23  

View as plain text