Skip to content
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

亀田の回答 #1

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

亀田の回答 #1

wants to merge 8 commits into from

Conversation

kmdsbng
Copy link

@kmdsbng kmdsbng commented Nov 7, 2013

回答書きました。レビューお願いします!

# -*- encoding: utf-8 -*-


class Codebreaker
Copy link
Member

Choose a reason for hiding this comment

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

ネームスペースとして使うなら module の方が向いているように思います。(他に理由があったらごめんなさい。)

Copy link
Author

Choose a reason for hiding this comment

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

確かにそうかも!
僕は特にこだわりなく、クラスにしてしまいます。

Copy link
Member

Choose a reason for hiding this comment

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

なんとなくRuby界隈ではネームスペースにmoduleを使う文化があるように思うのですが、この辺りは好みなのかもですね。

real_hit_count = total_hit_count - match_count
で求めるようにした。
total_hit_countを書きなおした
@kmdsbng
Copy link
Author

kmdsbng commented Nov 8, 2013

ひどい感じだったところを書き直しました。

  • class -> module に変えました
  • real_hit_count = total_hit_count - match_count で計算するようにしました。

@Sixeight
Copy link
Member

Sixeight commented Nov 8, 2013

👍


module Enumerable
def sum
self.inject(0) {|memo,i| memo + i}
Copy link
Member

Choose a reason for hiding this comment

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

無駄知識ですが、以下で同じ意味です。

inject(:+)

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
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants