-
Notifications
You must be signed in to change notification settings - Fork 48
Dionisia Edges calc_exercise.rb #37
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
base: master
Are you sure you want to change the base?
Conversation
CalculatorWhat We're Looking For
Hello Dionisia! Oh no! Your code didn't run when I looked at it. On running this code as is, it looks for a method Let's say that I change line 26 to user_entry = gets.chomp.downcaseWith this change, it doesn't check if the operator is valid, but it'll at least move forward. Then, the code gets stuck -- no matter what input you give it for the numbers, it will always believe that your input is not a number and print Well, the problem is in how you validate the number... you validate the number by calling the method By removing the call to Good work -- next time check that your code runs before submitting ;) |
| when "divide", "/" | ||
| div_total = num1 / num2 | ||
| puts "#{num1} / #{num2} = #{div_total}" | ||
| end |
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.
I'm being nitpicky, but this end should be on the same indentation as case (so, one less indentation). not a big deal, just a small note!
|
|
||
| # Verifying valid operators have been selected | ||
| def valid_num(number) | ||
| until (true if Float(number) rescue false) |
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.
In general, this reads kind of funny. Also, number will always be a float, since you get number from the call gets.chomp.to_f, which converts them to floats all the time.
Overall, the code works, but is just a little funny -- I wouldn't call this a high priority thing to correct, but something to return to in a few days or weeks with fresh eyes.
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions