Skip to content

bowling code#3

Open
rani-i3 wants to merge 3 commits into
mainfrom
ranibowling
Open

bowling code#3
rani-i3 wants to merge 3 commits into
mainfrom
ranibowling

Conversation

@rani-i3

@rani-i3 rani-i3 commented Aug 30, 2023

Copy link
Copy Markdown
Owner

No description provided.

Comment thread 02.calendar/calendar.rb
@@ -0,0 +1,46 @@
require 'date'

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

カレンダーのプログラムがPRに混じってしまっていますね。新しいブランチを作成する際は、今どのブランチにいるのかに注意して作成するようにしましょう。今回はこのままでOKです。

Comment thread 03.bowling/bowling.rb
end

frames = []
shots.each_slice(2) do |s|

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ここは以下のように書けますね。

frames = shots.each_slice(2).to_a

Comment thread 03.bowling/bowling.rb
# binding.break
if index >=9
point += frame.sum
# elsif frame_index == 11

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

不要であれば削除しておきましょう。3行↑にある binding.break も同様です。

Comment thread 03.bowling/bowling.rb
shots.each_slice(2) do |s|
frames << s
end
p frames

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

デバッグ用だと思うので、削除しておきましょう。

Comment thread 03.bowling/bowling.rb
p frames
point = 0

frames.each_with_index do |frame, index|

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

ここは以下のように Enumerable#sum を使うと、自分で point を加算しなくて良くなるはずです。

point = frames.each_with_index.sum do |frame, index|
  # 戻り値を各フレームのスコアにする
end

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants