Pipes - <Salome Wubeshet> - <Calculator>#32
Conversation
|
|
||
| def add(num1, num2) | ||
| return num1 + num2 | ||
| end |
There was a problem hiding this comment.
You're using tabs for indentation - please use two spaces per level of indentation instead. It doesn't make a big difference one way or the other, but keeping our style consistent across the class will make it much easier when we start doing group projects.
You can set your editor up to do this automatically, let me know if you need help with this.
|
|
||
| def division(num1, num2) | ||
| return num1 / num2 | ||
| end |
There was a problem hiding this comment.
I like that you've split these out into separate methods! It may seem a little pedantic for things like + and -, but for more complicated methods (imagine finding the least common multiple of two numbers, or even checking for zero before doing division) it results in much cleaner code.
| result = add(num1, num2) | ||
| puts "#{result}" | ||
| elsif(operation =='subtract' || operation == '-'|| operation == 'minus' ) | ||
| result = subtract(num1, num2) |
There was a problem hiding this comment.
You've got many lines here that all say puts #{result}. Would it be possible to DRY this code up somehow?
CalculatorWhat We're Looking For
Great work overall! |
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions