Working Super Fizz Buzz and Deaf Grandma drills and rspec tests.#85
Working Super Fizz Buzz and Deaf Grandma drills and rspec tests.#85ericnoble wants to merge 2 commits intopaircolumbus:masterfrom
Conversation
jaybobo
left a comment
There was a problem hiding this comment.
Looking good. Check out some of these comments.
| class SuperFizzBuzz | ||
|
|
||
| def run(input) | ||
| output = "" |
There was a problem hiding this comment.
Take a look at .tap.
https://ruby-doc.org/core-2.5.0/Object.html#method-i-tap
There was a problem hiding this comment.
I am not seeing it. How would I use .tap here to avoid initializing output to an empty string?
There was a problem hiding this comment.
You could use it to simplify your code a bit here because it returns itself. You'll see .tap used quite a bit. Let's say...
def run_service
api_service.tap do |s|
s.prepare_data
s.send_emails
s.log_something
end
endIn this particular case, you could...
"".tap do |fizz_buzz_string|
fizz_buzz_string << "Fizz" if condition
...
end
lib/fizzbuzz.rb
Outdated
| divBy5 = input % 5 == 0 | ||
|
|
||
| end | ||
| if divBy3 |
There was a problem hiding this comment.
snakecase_is_preferred.
https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars
lib/fizzbuzz.rb
Outdated
| end | ||
|
|
||
| if divBy3 || divBy5 | ||
| return output |
There was a problem hiding this comment.
Do you need an explicit return here?
https://stackoverflow.com/questions/1064159/implicit-return-values-in-ruby
lib/fizzbuzz.rb
Outdated
| if divBy3 || divBy5 | ||
| return output | ||
| else | ||
| return input |
lib/deaf_grandma.rb
Outdated
| if input == input.upcase | ||
| #YELL | ||
| if input == "BYE" | ||
| @bye_counter = @bye_counter + 1 |
There was a problem hiding this comment.
Please review @jaybobo .