Skip to content

第4回の課題(大倉) - #18

Open
ookura-mf wants to merge 4 commits into
mf-sakura:masterfrom
ookura-mf:daijin_no_kadai_syntax
Open

ookura-mf wants to merge 4 commits into
mf-sakura:masterfrom
ookura-mf:daijin_no_kadai_syntax

Conversation

@ookura-mf

Copy link
Copy Markdown

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
Comment thread syntax/map/main.go
}

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

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

Choose a reason for hiding this comment

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

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

@mf-sakura mf-sakura left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Comment thread syntax/for/main.go
Comment on lines +9 to +10
number := i
numbers = append(numbers, &number)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

Comment thread syntax/pointer/main.go
return n + 1
}
func incrementWithPointer(n *int) {
fmt.Printf("n's pointer is %v in incrementWithPointer\n", n)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

Comment thread syntax/map/main.go
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
Copy Markdown
Owner

Choose a reason for hiding this comment

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

👍

Comment thread syntax/map/main.go
}

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

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

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

Comment thread syntax/defer/main.go
Comment on lines +29 to +31
if err := file.Close(); err != nil {
fmt.Println("Error has occurred by file.Close().")
}

Copy link
Copy Markdown
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
Copy Markdown
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