Conversation
CalculatorWhat We're Looking For
Great job! The code works well and as expected, and the code looks good. I like that you reserved making methods for things that were reused. You also pulled out complexity into different methods -- I like the difference between the methods I'm leaving a few minor comments, but none of them are anything major. Overall, the code remained simple and elegant. Good work! |
| when "divide", "/" | ||
|
|
||
| # Handle cases when trying to divide by zero | ||
| if second_num == 0 then |
There was a problem hiding this comment.
you add in the then keyword to this... which is cool! I just wanted to call out that I don't see this syntax much, and I have no expectations for you to use it, unless it makes you happy.
| second = simplify_integer(second_num) | ||
| answer = simplify_integer(answer) | ||
|
|
||
| puts "#{first} #{symbol} #{second} = #{answer}" |
There was a problem hiding this comment.
if i were to prioritize conciseness over clarity/readability, i may suggest the following refactorings:
- renaming
simplify_integerto simply the nameformat, as if it were a method responsible for formatting the number to a human-readable string - renaming
first_numtofirstandsecond_numtosecond... - by getting those variable names back by inlining everything:
puts "#{format(first)} #{symbol} #{format(second)} = #{answer}"
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions