上一页 1 ··· 105 106 107 108 109 110 111 112 113 ··· 492 下一页
摘要: New is alernate way to create a variable new() function create a variable and returns a pointer to the variable Variable is initialized to zero packag 阅读全文
posted @ 2022-09-07 15:06 Zhentiw 阅读(20) 评论(0) 推荐(0)
摘要: Write a MinMaxStack class for a Min Max Stack. The class should support: Pushing and popping values on and off the stack. Peeking at the value at the 阅读全文
posted @ 2022-09-07 14:26 Zhentiw 阅读(36) 评论(0) 推荐(0)
摘要: Implement the built-in Omit<T, K> generic without using it. Constructs a type by picking all properties from T and then removing K For example interfa 阅读全文
posted @ 2022-09-06 15:03 Zhentiw 阅读(33) 评论(0) 推荐(0)
摘要: Implement the built-in ReturnType<T> generic without using it. For example const fn = (v: boolean) => { if (v) return 1 else return 2 } type a = MyRet 阅读全文
posted @ 2022-09-06 14:41 Zhentiw 阅读(35) 评论(0) 推荐(0)
摘要: // User type User struct { ID int FirstName string } // Method func (u *User) describe() string { desc := fmt.Sprintf("Name %s", u.FirstName) return d 阅读全文
posted @ 2022-09-06 02:31 Zhentiw 阅读(18) 评论(0) 推荐(0)
摘要: package main import ( "fmt" ) func recoverFromPanic() { fmt.Println("defer") } func doThings() { defer recoverFromPanic() for i := 0; i < 5; i++ { fmt 阅读全文
posted @ 2022-09-06 02:24 Zhentiw 阅读(29) 评论(0) 推荐(0)
摘要: package main import ( "errors" "fmt" "strings" ) func shouldGreaterThanTen(num int) error { if num < 10 { return errors.New("Number is less than 10") 阅读全文
posted @ 2022-09-06 02:15 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要: func changeName(name *string) { *name = strings.ToUpper(*name) } // Coordinates type Coordinates struct { X, Y float64 } func main() { name := "Elvis" 阅读全文
posted @ 2022-09-06 01:56 Zhentiw 阅读(21) 评论(0) 推荐(0)
摘要: var name string var namePointer *string // Pointer name = "Beyonce" namePointer = &name // Assign a Pointer fmt.Println("Name: ", name) fmt.Println("N 阅读全文
posted @ 2022-09-06 01:42 Zhentiw 阅读(24) 评论(0) 推荐(0)
摘要: package main import "fmt" type User struct { ID int FirstName string LastName string Email string } func main() { u := User{ID: 1, FirstName: "Z", Las 阅读全文
posted @ 2022-09-05 15:13 Zhentiw 阅读(16) 评论(0) 推荐(0)
上一页 1 ··· 105 106 107 108 109 110 111 112 113 ··· 492 下一页