A Tour of Go If
2014-10-26 22:54
260 查看
The
(Sound familiar?)
ifstatement looks as it does in C or Java, except that the
( )are gone and the
{ }are required.
(Sound familiar?)
package main import ( "fmt" "math" ) func sqrt(x float64) string{ if x < 0 { return sqrt(-x) + "i" } return fmt.Sprint(math.Sqrt(x)) } func main() { fmt.Println(sqrt(2), sqrt(-4)) }
相关文章推荐
- A Tour of Go If and else
- A Tour of Go Structs
- A Tour of Go Map literals continued
- A Tour of Go Mutating Maps
- A Tour of Go Concurrency
- A Tour of Go Exercise: Maps
- A Tour of Go Interfaces
- A Tour of Go Channels
- A Tour of Go Function closures
- A Tour of Go Errors
- A Tour of Go Buffered Channels
- A Tour of Go---Exercise: Fibonacci closure
- 【Go语言(golang)教程】A Tour of Go 七十集大全
- A Tour of Go Struct Literals
- A Tour of Go Switch
- A Tour of Go:开始!
- A Tour of Go : Exercise: Slices
- A tour of Go的疑问
- A Tour of Go Multiple results
- A Tour of Go Arrays