Open
Conversation
Calculator exercise
CalculatorWhat We're Looking For
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! |
|
|
||
| def numberic?(string) | ||
| /[%\+\*\d]/.match(string) | ||
| end |
There was a problem hiding this comment.
I think the spelling you're looking for here is numeric?.
| def type?(input) | ||
| if /\A\d+\z/.match(input) | ||
| return "integer" | ||
| elsif /\A\d+\.\d+\z/.match(input) |
There was a problem hiding this comment.
I really like that you've split all these off into helper methods - good organization!
| # this will allow the program to know if the result should be printed as a float or an integer | ||
| if type?(num1) == "float" | ||
| results.to_f | ||
| elsif type?(num1) == "integer" && type?(num2) == "integer" |
There was a problem hiding this comment.
This conditional could be simplified a bit:
if type?(num1) == "integer" && type?(num2) == "integer"
results.to_i
else
results.to_f
endAlso, you're turning result into an integer or a float here, but you don't do anything with the modified value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Calculator exercise
Calculator
Congratulations! You're submitting your assignment.
Comprehension Questions