Conversation
CalculatorWhat We're Looking For
Well done on this project, Sara! Your code works well and reads well. If you had more time on this project, I would encourage you to consider two things:
I've also added some comments about small suggestions on how to improve your code. That being said, you did well on this. Good work! |
|
|
||
| # ask user to input an maths operater until its valid | ||
| until math_operators.include?(math_operater) | ||
| puts"Invalid math operator! Please try again." |
There was a problem hiding this comment.
This is very minor, but I like having spaces inbetween my methods and strings, so I'd like a space between puts and the string, like puts "Invalid math operator!"
| num_one = Integer(gets.chomp) | ||
| rescue ArgumentError => e | ||
| puts "You did not enter a a number. Try again!" | ||
| end |
There was a problem hiding this comment.
Hm, I'm looking at this above begin ... rescue section. You end up having this exact logic down below, inside of an until loop... What happens if we replace this above logic with this?
print "Please enter the first number: "
num_one = Integer(gets.chomp) | num_one = Integer(gets.chomp) | ||
| rescue ArgumentError => e | ||
| puts "You did not enter a a number. Try again!" | ||
| end |
There was a problem hiding this comment.
We will get into begin ... rescue clauses in-depth later in the program! For now, this is an okay solution, but it may be interesting to consider what it would look like without using the begin ... rescue
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions