码迷,mamicode.com
首页 >  
搜索关键字:func    ( 15298个结果
A Tour of Go Range continued
You can skip the index or value by assigning to_.If you only want the index, drop the ", value" entirely.package main import "fmt"func main() { pow...
分类:其他好文   时间:2014-10-27 06:54:42    阅读次数:224
A Tour of Go Range
Therangeform of theforloop iterates over a slice or map.package mainimport "fmt"var pow = []int{1, 2, 4, 8, 16, 32, 64, 128}func main() { for i, v ...
分类:其他好文   时间:2014-10-27 06:52:09    阅读次数:183
A Tour of Go Slices
A slice points to an array of values and also includes a length.[]Tis a slice with elements of typeT.package main import "fmt"func main() { p := []...
分类:其他好文   时间:2014-10-27 01:45:20    阅读次数:222
A Tour of Go If and else
Variables declared inside anifshort statement are also available inside any of theelseblocks.package main import ( "fmt" "math")func pow(x, n, ...
分类:其他好文   时间:2014-10-27 00:23:52    阅读次数:165
A Tour of Go Forever
If you omit the loop condition it loops forever, so an infinite loop is compactly(简洁地;紧密地;细密地) expressed.package main func main() { for { ...
分类:其他好文   时间:2014-10-27 00:20:36    阅读次数:239
A Tour of Go Structs
Astructis a collection of fields.(And atypedeclaration does what you'd expect.)package main import "fmt"type Vertext struct { X int Y int}func ...
分类:其他好文   时间:2014-10-27 00:17:33    阅读次数:190
A Tour of Go Struct Fields
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 ...
分类:其他好文   时间:2014-10-27 00:13:16    阅读次数:248
A Tour of Go For continued
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...
分类:其他好文   时间:2014-10-27 00:10:35    阅读次数:221
A Tour of Go For is Go's "while"
At that point you can drop the semicolons(分号): C'swhileis spelledforin Go.package main import "fmt"func main() { sum := 1 for sum < 1000 { ...
分类:其他好文   时间:2014-10-27 00:10:05    阅读次数:213
A Tour of Go Multiple results
A function can return any number of results.This function returns two strings.package mainimport "fmt"func swap(x, y string) (string, string) { ret...
分类:其他好文   时间:2014-10-26 21:00:32    阅读次数:143
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!