上一页 1 ··· 83 84 85 86 87 88 89 90 91 ··· 469 下一页
摘要: An array has a fixed size. A slice, on the other hand, is a dynamically-sized, flexible view into the elements of an array. In practice, slices are mu 阅读全文
posted @ 2022-09-05 14:11 Zhentiw 阅读(17) 评论(0) 推荐(0) 编辑
摘要: Slices can be created with the built-in make function; this is how you create dynamically sized arrays. The make function allocates a zeroed array and 阅读全文
posted @ 2022-09-04 22:50 Zhentiw 阅读(15) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" ) func main() { //var scores [5]float64 //fmt.Println(scores) // [0.0, 0.0,0.0,0.0,0.0] //var scores [5]float64 = [5]float 阅读全文
posted @ 2022-09-04 20:13 Zhentiw 阅读(10) 评论(0) 推荐(0) 编辑
摘要: Function can return multi values: func printAge(age int) (int, int) { return 12, age } func main() { age1, age2 := printAge(8) fmt.Println(age1) fmt.P 阅读全文
posted @ 2022-09-04 20:07 Zhentiw 阅读(11) 评论(0) 推荐(0) 编辑
摘要: There is no While loop in Go, but you can use For loop as while loop: i := 1 for i < 100 { fmt.Println(i) i += 1 } func main() { var myTxt = "This is 阅读全文
posted @ 2022-09-04 16:29 Zhentiw 阅读(11) 评论(0) 推荐(0) 编辑
摘要: fallthrough keyword is used in switch statement in golang. This keyword is used in switch case block. If the fallthrough keyword is present in the cas 阅读全文
posted @ 2022-09-04 16:19 Zhentiw 阅读(36) 评论(0) 推荐(0) 编辑
摘要: // Defined a err variable err and assige the return value of someFunction() // err only available in if {} block, not outside if err := someFunction() 阅读全文
posted @ 2022-09-04 16:02 Zhentiw 阅读(18) 评论(0) 推荐(0) 编辑
摘要: package main import ( "fmt" ) func main() { var firstName string = "firstName" var lastName = "lastName" var fullName string // Go will assign default 阅读全文
posted @ 2022-09-04 15:58 Zhentiw 阅读(14) 评论(0) 推荐(0) 编辑
摘要: Can use reflect.TypeOf to get variable type package main import ( "fmt" "reflect" ) func main() { // var age int = 21 // var b bool = age >= 23 var ag 阅读全文
posted @ 2022-09-04 15:52 Zhentiw 阅读(26) 评论(0) 推荐(0) 编辑
摘要: Implement the built-in Parameters generic without using it. For example: const foo = (arg1: string, arg2: number): void => {} type FunctionParamsType 阅读全文
posted @ 2022-09-03 23:44 Zhentiw 阅读(19) 评论(0) 推荐(0) 编辑
上一页 1 ··· 83 84 85 86 87 88 89 90 91 ··· 469 下一页