2023-01-09:以下go语言代码输出什么?A:+Inf; B:zero; C:something else

2023-01-09:以下go语言代码输出什么?A:+Inf; B:zero; C:something else; D:doesn’t compile。

package main

import (
    "fmt"
    "math"
)

func main() {
    // Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.
    x := math.Inf(1)
    switch {
    case x < 0, x > 0:
        fmt.Println(x)
    case x == 0:
        fmt.Println("zero")
    default:
        fmt.Println("something else")
    }
}




























答案选A。这道题考的不是语法,而是英语。根据注释 Inf returns positive infinity if sign >= 0, negative infinity if sign < 0.,即可得出答案。
在这里插入图片描述

本作品采用《CC 协议》,转载必须注明作者和本文链接
微信公众号:福大大架构师每日一题。最新面试题,涉及golang,rust,mysql,redis,云原生,算法,分布式,网络,操作系统。
讨论数量: 0
(= ̄ω ̄=)··· 暂无内容!

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!
未填写
文章
464
粉丝
21
喜欢
37
收藏
22
排名:461
访问:1.9 万
私信
所有博文
社区赞助商