Skip to content

第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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

ookura-mf
Copy link

No description provided.

@ookura-mf ookura-mf changed the title deferの課題 第4回の課題(大倉) Apr 1, 2020
@ookura-mf ookura-mf marked this pull request as ready for review April 1, 2020 15:54
3: "田中",
1: "伊藤",
2: "佐藤",
4: "佐々木",
}

for k, v := range studnetIDMap {
studentIDSlice := make([]int, len(studentIDMap))
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

mapからslice作れんかなぁと思ったのですが、無理っぽかったので愚直に詰めました

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自分の知る限りそういうメソッドはないので、自前で変換する必要があります:pray:

Copy link
Owner

@mf-sakura mf-sakura left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ookura-mf
第四回の課題にコメントしました:pray:

Comment on lines +9 to +10
number := i
numbers = append(numbers, &number)
Copy link
Owner

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)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment on lines +29 to +36
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 {
Copy link
Owner

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))
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

自分の知る限りそういうメソッドはないので、自前で変換する必要があります:pray:

Comment on lines +29 to +31
if err := file.Close(); err != nil {
fmt.Println("Error has occurred by file.Close().")
}
Copy link
Owner

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
}

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

なるほど

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants