mirror of
https://gitee.com/shikong-sk/golang-study
synced 2025-02-22 23:12:15 +08:00
docs: Boolean 布尔
This commit is contained in:
parent
eb1ba1af27
commit
9262520ce6
13
base/boolean/main.go
Normal file
13
base/boolean/main.go
Normal file
@ -0,0 +1,13 @@
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func main() {
|
||||
// 在 golang 中 不允许 从其他类型 强制转换 到 bool 类型
|
||||
b1 := true
|
||||
// bool 默认为 false
|
||||
var b2 bool
|
||||
|
||||
// %T 打印变量类型
|
||||
fmt.Printf("b1: %T %t\nb2: %T %t\n", b1, b1, b2, b2)
|
||||
}
|
Loading…
Reference in New Issue
Block a user