美文网首页Go
Go if with a statement

Go if with a statement

作者: JaedenKil | 来源:发表于2019-03-05 15:10 被阅读0次
package main

import (
    "fmt"
    "math"
)

func main() {
    fmt.Println(
        pow(3, 2, 10),
        pow(3, 3, 20),
    )
}

func pow(x, n, lim float64) float64 {
    if v := math.Pow(x, n); v < lim {
        return v
    }
    return lim
}

Outputs:

9 20

相关文章

网友评论

    本文标题:Go if with a statement

    本文链接:https://www.haomeiwen.com/subject/ctjnuqtx.html