上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 40 下一页
摘要: Struct fields are accessed using a dot.package main import "fmt"type Vertex struct { X int Y int}func main() { v := Vertex{1, 2} v.X = 4 ... 阅读全文
posted @ 2014-10-26 23:26 wuhn 阅读(159) 评论(0) 推荐(0) 编辑
摘要: Astructis a collection of fields.(And atypedeclaration does what you'd expect.)package main import "fmt"type Vertext struct { X int Y int}func ... 阅读全文
posted @ 2014-10-26 23:24 wuhn 阅读(151) 评论(0) 推荐(0) 编辑
摘要: As a simple way to play with functions and loops, implement the square root function using Newton's method.In this case, Newton's method is to approxi... 阅读全文
posted @ 2014-10-26 23:22 wuhn 阅读(329) 评论(0) 推荐(0) 编辑
摘要: Variables declared inside anifshort statement are also available inside any of theelseblocks.package main import ( "fmt" "math")func pow(x, n, ... 阅读全文
posted @ 2014-10-26 23:06 wuhn 阅读(140) 评论(0) 推荐(0) 编辑
摘要: Likefor, theifstatement can start with a short statement to execute before the condition.Variables declared by the statement are only in scope until t... 阅读全文
posted @ 2014-10-26 23:02 wuhn 阅读(149) 评论(0) 推荐(0) 编辑
摘要: Theifstatement looks as it does in C or Java, except that the( )are gone and the{ }are required.(Sound familiar?)package main import ( "fmt" "m... 阅读全文
posted @ 2014-10-26 22:54 wuhn 阅读(163) 评论(0) 推荐(0) 编辑
摘要: If you omit the loop condition it loops forever, so an infinite loop is compactly(简洁地;紧密地;细密地) expressed.package main func main() { for { ... 阅读全文
posted @ 2014-10-26 22:49 wuhn 阅读(107) 评论(0) 推荐(0) 编辑
摘要: At that point you can drop the semicolons(分号): C'swhileis spelledforin Go.package main import "fmt"func main() { sum := 1 for sum < 1000 { ... 阅读全文
posted @ 2014-10-26 22:47 wuhn 阅读(137) 评论(0) 推荐(0) 编辑
摘要: As in C or Java, you can leave the pre and post statements empty.package main import "fmt"func main() { sum := 1 for ; sum < 1000; { sum... 阅读全文
posted @ 2014-10-26 22:45 wuhn 阅读(136) 评论(0) 推荐(0) 编辑
摘要: Go has only one looping construct, theforloop.The basicforloop looks as it does in C or Java, except that the( )are gone (they are not even optional) ... 阅读全文
posted @ 2014-10-26 22:42 wuhn 阅读(156) 评论(0) 推荐(0) 编辑
上一页 1 ··· 11 12 13 14 15 16 17 18 19 ··· 40 下一页