# 公式資料
Effective Go - The Go Programming Language Go Slices: usage and internals - The Go Blog
| GET https://api.line.me/v2/bot/message/{messageId}/content |
| let myVariable: Int = { | |
| while(true){} | |
| }() |
| var myVariable = 42 | |
| let r = (myVariable = 50) //Void | |
| (obj?.myVariable = 50) //Optional<Void> |
| package main | |
| import ( | |
| "fmt" | |
| ) | |
| func Sqrt(x float64) float64 { | |
| z := 1.0 | |
| package main | |
| import "fmt" | |
| const ( | |
| // Shift it right again 99 places, so we end up with 1<<1, or 2. | |
| Small = Big >> 99 | |
| // Create a huge number by shifting a 1 bit left 100 places. | |
| // In other words, the binary number that is 1 followed by 100 zeroes. | |
| Big = 1 << 100 |
| package main | |
| import ( | |
| "fmt" | |
| "math/cmplx" | |
| ) | |
| var ( | |
| ToBe bool = false | |
| MaxInt uint64 = 1<<64 - 1 |
| package main | |
| import "fmt" | |
| func main() { | |
| var i, j int = 1, 2 | |
| k := 3 | |
| c, python, java := true, false, "no!" | |
| fmt.Println(i, j, k, c, python, java) |
| package main | |
| import ( | |
| "fmt" | |
| r "math/rand" | |
| ) | |
| func main() { | |
| fmt.Println("My favorite number is", r.Intn(10)) | |
| } |
| extension Bool { | |
| struct Extension { | |
| let value: Bool | |
| func toggle() -> Bool { | |
| return !value | |
| } | |
| } | |
| var `extension`: Extension { | |
| return Extension(value: self) |