Conversation
# calculator project
CalculatorWhat We're Looking For
In response to your PR comments, the spacing on your methods works fine, but where you've defined them is a little odd - see below. For large numbers, commas are a little tricky but you can use underscores instead: Great job overall! I have a couple of inline comments below that you should check out, but in general I am quite happy with this submission. Keep up the hard work! |
| # divide | ||
| def divide(num1, num2) | ||
| if num2 != 0 | ||
|
|
There was a problem hiding this comment.
This divide method is defined inside your while loop! While this is technically valid Ruby (and certainly works), it's a little odd to me as a reader. A better option might be to define all your methods at the very top of the file, and have your main control loop below that.
| def multiply(num1, num2) | ||
|
|
||
| print "#{num1} * #{num2} = " | ||
| (num1 * num2).round(2) |
There was a problem hiding this comment.
Printing out the equation inside the method is one way to solve this optional, but it's not always ideal, because it means your method is doing two different things: doing some math problem, and printing an equation. This takes control away from whoever's calling your method. There's no way to do multiplication without also putsing something to the screen.
In general, you should try to make your methods do only one thing.
calculator project
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions