-
Notifications
You must be signed in to change notification settings - Fork 48
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
Create calculator.rb #22
base: master
Are you sure you want to change the base?
Conversation
CalculatorWhat We're Looking For
|
end | ||
|
||
# methods used | ||
def add(num1, num2) |
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.
This is more of a style thing. It's a little odd putting the method definitions here in the middle of the program flow. I suggest moving method definitions to the top of the file.
operation = gets.chop.downcase | ||
end | ||
|
||
# collects two numbers for calculation |
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.
Do you think this method block could be turned into a reusable method?
puts "#{value_1} * #{value_2} = #{solution}" | ||
|
||
elsif operation == "/" || operation == "solution" | ||
if value_1 == 0 || value_2 == 0 |
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.
Dividing something by zero is not zero. It's undefined.
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions