for i := 0; i < 8; i++ {
buf = (buf << 8) | uint64(bitMap[i])
}
这是语法糖么?
写个例子打印一下就出来了:
```
func main() {
var buf int64 = 1
for i := 0; i < 8; i++ {
temp := buf << 8 //左移:整型表达式<<整型表达式
buf = temp | int64(1) //按位或:整型表达式|整型表达式
fmt.Println("temp: ",temp)
fmt.Println(" buf: ",buf)
}
}
```
=============打印结果:===================================
```
temp: 256
buf: 257
temp: 65792
buf: 65793
temp: 16843008
buf: 16843009
temp: 4311810304
buf: 4311810305
temp: 1103823438080
buf: 1103823438081
temp: 282578800148736
buf: 282578800148737
temp: 72340172838076672
buf: 72340172838076673
temp: 72340172838076672
buf: 72340172838076673
```
#5
更多评论