-
Notifications
You must be signed in to change notification settings - Fork 0
fizzbuzzプログラムを作成 #1
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: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| (1..20).each { |n| | ||
| (puts "FizzBuzz"; next) if n.modulo(3 * 5) == 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 行末に余分なスペースが入っています。エディタの設定で「保存時に行末スペースを削除する」をオンにしておくと、こういったものを自動で防げます。 また、 |
||
| (puts "Buzz"; next) if n.modulo(5) == 0 | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 2行目と同様、行末に余分なスペースが入っています。 |
||
| (puts "Fizz"; next) if n.modulo(3) == 0 | ||
| puts n | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 行末に余分なスペースが入っています。こちらも合わせて取り除いてください。 |
||
| } | ||
|
|
||
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.
Rubyの
eachにブロックを渡すとき、複数行の場合は{}ではなくdo...endを使うのが慣例です。1行で書く場合は
{}、複数行の場合はdo...endという使い分けを覚えておくと良いです。