-
Notifications
You must be signed in to change notification settings - Fork 25
第4回の課題(大倉) #18
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
第4回の課題(大倉) #18
Conversation
3: "田中", | ||
1: "伊藤", | ||
2: "佐藤", | ||
4: "佐々木", | ||
} | ||
|
||
for k, v := range studnetIDMap { | ||
studentIDSlice := make([]int, len(studentIDMap)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mapからslice作れんかなぁと思ったのですが、無理っぽかったので愚直に詰めました
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
自分の知る限りそういうメソッドはないので、自前で変換する必要があります:pray:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ookura-mf
第四回の課題にコメントしました:pray:
number := i | ||
numbers = append(numbers, &number) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
return n + 1 | ||
} | ||
func incrementWithPointer(n *int) { | ||
fmt.Printf("n's pointer is %v in incrementWithPointer\n", n) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
index := 0 | ||
for key := range studentIDMap { | ||
studentIDSlice[index] = key | ||
index++ | ||
} | ||
sort.Slice(studentIDSlice, func(i, j int) bool { return studentIDSlice[i] < studentIDSlice[j] }) | ||
|
||
for _, key := range studentIDSlice { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
3: "田中", | ||
1: "伊藤", | ||
2: "佐藤", | ||
4: "佐々木", | ||
} | ||
|
||
for k, v := range studnetIDMap { | ||
studentIDSlice := make([]int, len(studentIDMap)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
自分の知る限りそういうメソッドはないので、自前で変換する必要があります:pray:
if err := file.Close(); err != nil { | ||
fmt.Println("Error has occurred by file.Close().") | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ここのエラーを呼び出し元に返す場合は、第5回の解説で説明した通り以下の様な実装にするのが良いです。
if closeErr := file.Close(); closeErr != nil {
err = closeErr
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
なるほど
No description provided.